static-linking

Visual Studio Static Linking for Standalone Exe

笑着哭i 提交于 2020-02-23 03:39:33
问题 I've read multiple posts with regards to this topic, but none of them have enabled me to build a statically linked exe. In my release configuration (x64) I have the following: Configuration Properties -> General : Use of MFC - Use MFC in a Static Library Configuration Properties -> C/C++ -> Code Generation : Runtime Library - Multi-threaded (/MT) Configuration Properties -> Linker -> Command Line : Additional Options - I have all the required Windows libs "kernel32.lib", etc. (as use of MFC

c -lz library link order (undefined reference to symbol “inflateInit2_”)

若如初见. 提交于 2020-01-30 02:45:34
问题 I link the the library in CodeBlocks in this order, -lz -L/usr/local/lib -L/usr/local/include -pthread -lswscale -lavutil -lavcodec -lmp3lame -lopus -ltiff -lvorbis -ltheora -ltheoraenc -ltheoradec -lvorbisenc -ltiffxx -llzma -lva -lavfilter -lavformat -lfreetype still got error: undefined reference to symbol "inflateInit2_" I am wondering whether it is the library link order problem? Where should I put the -lz? 回答1: For GCC and Clang (and probably e.g. the Intel compiler too) the rule is

Link static library using CMake

≡放荡痞女 提交于 2020-01-28 10:58:06
问题 I cannot get the library ${static_library} to statically link using CMake. I have tried hard coding the path and as far as I'm aware TARGET_LINK_LIBRARIES should link this in automatically. ADD_LIBRARY(libraryA STATIC ${source_files}) TARGET_LINK_LIBRARIES(libraryA debug ${static_library}) There is a sub project that links libraryA later in the build ADD_EXECUTABLE(testA ${test_sources}) TARGET_LINK_LIBRARIES(testA libraryA) which has ${static_library} correctly linked in but I need ${static

Link static library using CMake

时间秒杀一切 提交于 2020-01-28 10:56:02
问题 I cannot get the library ${static_library} to statically link using CMake. I have tried hard coding the path and as far as I'm aware TARGET_LINK_LIBRARIES should link this in automatically. ADD_LIBRARY(libraryA STATIC ${source_files}) TARGET_LINK_LIBRARIES(libraryA debug ${static_library}) There is a sub project that links libraryA later in the build ADD_EXECUTABLE(testA ${test_sources}) TARGET_LINK_LIBRARIES(testA libraryA) which has ${static_library} correctly linked in but I need ${static

Why specify particular library in Visual Studio if the path to lib is known? [closed]

戏子无情 提交于 2020-01-25 20:26:47
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . TL/DR: Question start with steps that I've made and that I think are important to mention (let me know if it is not important and I will delete it). The question itself is in the bottom of page. I've posted 3 questions that has the same steps that I've issued before asking the

Ordering of object files and libraries in static linking

本秂侑毒 提交于 2020-01-25 00:41:07
问题 I've created a simple static library libvec.a with AR tool from simple addv.o and multo.o . The object file addv.o contains 1 function symbol ( addvec ) and multo.o contains 1 function ( multvec ). I have also written a simple program to test it ( driver.c which adds 2 vectors and uses addvec function from the library; also it has included vector.h that defines the function prototypes). And then I compiled it with gcc -static driver.o ./libvec.a and everything went okay. But at first I tried

Static ZLIB (1.2.8) linking on Visual Studio 2012

北城以北 提交于 2020-01-23 05:53:34
问题 I can't, for the love of God, to static link the ZLIB libs. I have been struggling for a couple hours now with no success. Well, I have followed this tutorial and successfuly compiled both zlibstat.lib and zlibwapi.lib for 32 bits. After setting up my project to use the ZLIB folder with the libraries (Linker > General > Additional Library Directories) and setting zlibwapi.lib (only) as an dependency (Linker > Input > Additional Dependencies) I got it to work , however, that was a dynamic link

How to link a .lib in Visual Studio 2008 C++

北慕城南 提交于 2020-01-23 02:45:08
问题 I'm finding it really difficult to properly link a .lib file to my C++ Win32 Console Application. Here's my problem. Just as in this MSDN article, I have developed a MathFuncsLib.lib file. http://msdn.microsoft.com/en-us/library/ms235627%28v=vs.80%29.aspx Then, in the MyExecRefsLib Win32 Console App, I want to link to the above file. So, inside MyExecRefsLib folder (same folder where .sln file resides) I created a directory called "LibraryFiles" and placed both MathFuncsLib.lib file AND

Why doesn't the linker complain of duplicate symbols?

前提是你 提交于 2020-01-20 08:26:25
问题 I have a dummy.hpp #ifndef DUMMY #define DUMMY void dummy(); #endif and a dummy.cpp #include <iostream> void dummy() { std::cerr << "dummy" << std::endl; } and a main.cpp which use dummy() #include "dummy.hpp" int main(){ dummy(); return 0; } Then I compiled dummy.cpp to three libraries, libdummy1.a , libdummy2.a , libdummy.so : g++ -c -fPIC dummy.cpp ar rvs libdummy1.a dummy.o ar rvs libdummy2.a dummy.o g++ -shared -fPIC -o libdummy.so dummy.cpp When I try compile main and link the dummy

Why doesn't the linker complain of duplicate symbols?

徘徊边缘 提交于 2020-01-20 08:25:55
问题 I have a dummy.hpp #ifndef DUMMY #define DUMMY void dummy(); #endif and a dummy.cpp #include <iostream> void dummy() { std::cerr << "dummy" << std::endl; } and a main.cpp which use dummy() #include "dummy.hpp" int main(){ dummy(); return 0; } Then I compiled dummy.cpp to three libraries, libdummy1.a , libdummy2.a , libdummy.so : g++ -c -fPIC dummy.cpp ar rvs libdummy1.a dummy.o ar rvs libdummy2.a dummy.o g++ -shared -fPIC -o libdummy.so dummy.cpp When I try compile main and link the dummy