However, when I try to run it from the EXE file, it still expects DLL files. addlibrary STATIC STATIC addlibrary (xlog xlog.cpp) cmake STATIC SHARED addlibrary (xlog SHARED xlog.cpp) LinuxWindows declspec (dllexport)lib CMakeLists.txt cmake -S. gcc -static -O0 -g main.c /usr/lib/x8664-linux-gnu/libpthread. Since you do not seem to build the dependency as part of the CMake project, the only way to obtain a CMake target to link against, is to create an imported target. Sometimes a project needs to specifically link external or internal static libs, even if shared libs are present. 1 I am trying to achieve the equivalent of following command by CMake. Solution 1 You should always try to give either full paths or CMake targets to targetlinklibraries. The application works well when I run it within my IDE. CMake by default searches for shared libs before static libs. So I guess linking process was successful. In Part 1, we will create a dynamic link library (DLL) file in Visual Studio to perform object. The list of standard modules is in the official documentation. How can I link a static library with cmake The library Im trying to link is in the project directory lib/lib.a and the only source file is main.cpp. In ORT, memory allocation is not attached with cuda stream. CMake comes with numerous modules that aid in finding various well-known libraries and packages. Then rebuilt the application, EXE size increased to 1.6 MB from 200 KB. To link external libraries, best practice is to use or create FindModule for given external library. I edited the environment variable for the new build of OpenCV, my IDE does see include directories and files, so this step also seems ok.Īdded "-static" parameter to target_link_libraries command in CMake: target_link_libraries(HoGPeopleDetector $ "-static") I built OpenCV from source by setting BUILD_SHARED_LIBS to OFF, so I can see library files under lib directory. g, using debug versions of the standard and runtime. I'm trying to statically link my C++ (CMake) application to run on another computer which does not have OpenCV installed. linking statically to the C++ standard library and compiler runtime support libraries. You can take a look at my post on the OpenCV Q&A page.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |