Below code failed to run, why? How to fix?
– Performing Test STATIC_SYSTEM_LIBS
– Performing Test STATIC_SYSTEM_LIBS - Failed
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++ -Wl,-z,defs")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
check_cxx_source_runs("int main() { return 0; }" STATIC_SYSTEM_LIBS)
if (NOT STATIC_SYSTEM_LIBS)
message(WARNING "You are missing one or more static system libraries that will be linked by -static-libgcc -static-libstdc++")
endif()
There are no such log existed. below are all the file lists:
cmake.check_cache
Makefile.cmake
Makefile2
nfiq2api.dir
progress.marks
nfiq2.dir
OpenCV.dir
TargetDirectories.txt
CMakeRuleHashes.txt
CMakeDirectoryInformation.cmake
CMakeConfigureLog.yaml
CMakeScratch
3.26.3
feature_tests.bin
pkgRedirects
include(CheckCXXSourceRuns)
cmake_minimum_required(VERSION 3.5)
project(HelloWorld C CXX)
include_directories(${PROJECT_SOURCE_DIR})
add_executable(hello hello.cpp)
add_executable(hello2 hello.c)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++ -Wl,-z,defs")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
check_cxx_source_runs ("int main() { return 0; }" STATIC_SYSTEM_LIBS)
if (NOT STATIC_SYSTEM_LIBS)
message(WARNING "You are missing one or more static system libraries that will be linked by -static-libgcc -static-libstdc++")
endif()
hello.c
#include "stdio.h"
int main()
{
printf("this is just a test\n");
return 0;
}
hello.cpp:
#include <iostream>
int main()
{
for (int i = 0; i < Times; i++)
{
std::cout << "Hello, world!" << std::endl;
}
return 0;
}
and run cmake -B build .
and it got successs.
Can you please try the above?
Yes, now the question is why it failed on NFIQ2 source code build? I extracted that part of code and it succeeded as both of us tested. Why failed there?
It did not pass for me; I also saw – Performing Test STATIC_SYSTEM_LIBS - Failed because I do not have the libraries referenced installed on my machine.
I have yet to see any output that shows the try_compile succeeding on your setup. You’ve said it builds, but this does not mean the try_compile worked as it only raises a warning, not an error.