linker

In class static const ODR

橙三吉。 提交于 2019-12-18 13:27:47
问题 I am a bit confused by the static in-class initialization of a const member. For example, in the code below: #include <iostream> struct Foo { const static int n = 42; }; // const int Foo::n; // No ODR void f(const int& param) { std::cout << param << std::endl; } int g(const int& param) { return param; } template<int N> void h() { std::cout << N << std::endl; } int main() { // f(Foo::n); // linker error, both g++/clang++ std::cout << g(Foo::n) << std::endl; // OK in g++ only with -O(1,2 or 3)

VS2010 static linking issue

谁说胖子不能爱 提交于 2019-12-18 13:09:52
问题 my company has recently upgraded from VS2005 to VS2010. We have a huge project which uses a lot of modules which are being linked statically into the exe. But there seem to be some issues with linking in VS2010. To explain our problem, we've built a minimal example project which is composed as shown on this graphic: There is an application using one function from library A. Library A calls one function of each library B and library C. Those two libraries call a function provided by library D.

Linking *.lib files with MinGW

試著忘記壹切 提交于 2019-12-18 12:49:31
问题 Is it possible to Link *.lib files with MinGW(I use it with Eclipse) unambiguous information about that. I'm fighting with libcurl+OpenSSL so now I don't understand if my errors are because I try to use .lib-files in MinGW or something else is wrong 回答1: Probably not. mingw's static library format is *.a. Dynamic libraries for a given platform are standardized by the OS loader that must be able to load them. Static libraries only have to be understood by the toolchain's linker, and are thus

Circular Inclusion with Templates

ε祈祈猫儿з 提交于 2019-12-18 12:44:28
问题 The following code compiles perfectly: // MyFile.h #ifndef MYFILE_H_INCLUDED #define MYFILE_H_INCLUDED template <typename Datatype> class MyClass { public: void MyMethod(); } #include "MyFile.cpp" #endif // MyFile.cpp #ifndef MYFILE_CPP_INCLUDED #define MYFILE_CPP_INCLUDED #include "MyFile.h" template <typename Datatype> void MyClass<Datatype>::MyMethod() { // ... } #endif The definitions of other methods and functions can be separated from the declarations in the same manner. Are there any

Apple Mach -O Linker (Id) Error?

眉间皱痕 提交于 2019-12-18 12:19:07
问题 I am trying to build this xcode workspace which was built from Unity. And after modifying the project a little bit when I getting to the very end of building the project (linking) I get the Apple Mach -O Linker (Id) Error. I can't open the error tab to see what exactly is causing the error. All it says is "Linker command failed with exit code 1 (use -v to see invocation). There are also two Apple Mach -O Linker (Id) Errors which occur but I have no idea how to solve them. Any help is greatly

correct usage of rpath (relative vs absolute)

血红的双手。 提交于 2019-12-18 11:52:47
问题 When building a binary or library, specifying the rpath , i.e. -Wl,rpath,<path/to/lib> tells the linker where to find the required library at runtime of the binary. What is the UNIX philosphy regarding absolute and relative paths here? Is it better to use an absolute path so the lib can be found from everywhere? Or is it better to make it relative so copying an entire directory or renaming a higher level path won't render the binary unusable? Update Using $ORIGIN is usually the preferred way

correct usage of rpath (relative vs absolute)

谁说胖子不能爱 提交于 2019-12-18 11:52:08
问题 When building a binary or library, specifying the rpath , i.e. -Wl,rpath,<path/to/lib> tells the linker where to find the required library at runtime of the binary. What is the UNIX philosphy regarding absolute and relative paths here? Is it better to use an absolute path so the lib can be found from everywhere? Or is it better to make it relative so copying an entire directory or renaming a higher level path won't render the binary unusable? Update Using $ORIGIN is usually the preferred way

LNK1201 Visual C++ 2010 Large project failing to generate PDB

雨燕双飞 提交于 2019-12-18 11:33:03
问题 We have gone through the points listed on MSDN WRT to this error ( except for #5 ). Three different people on different machines are getting the same problem. The PDB is created, but fails somewhere in the middle. Details: 67 static libraries 4.27 GB of static libraries 1048575 bytes - size of PDB when linker fails The last couple of megabytes of the PDB are null ( zero's ) Release build succeeds & produces a PDB ( we have it turn on, with no debugging info in the exe ) Release build PDB is

What's the difference between gtest.lib and gtest_main.lib?

天涯浪子 提交于 2019-12-18 11:20:53
问题 Google's C++ Test Framework has two output libraries: one is gtest.lib and the other one is gtest_main.lib. According to Nik Reiman's answer on how to setup gtest with Visual Studio, we should link to gtest_main.lib but I'm linking to gtest.lib and the sample test cases that I have are running fine. What's the difference between the two libraries and does it matter which one I link to? 回答1: the only reasonable difference is that gtest_main.lib provides a default implementation of a test

How to get RPATH with $ORIGIN to work on Code::Blocks GCC?

雨燕双飞 提交于 2019-12-18 11:08:04
问题 I'm trying to link an RPATH containing the special string $ORIGIN into an executable built using GCC with the Code::Blocks IDE. I've specified -Wl,-R$ORIGIN in the linker options for the project, but the command line output to GCC is wrong (stripped for clarity): g++ -Wl,-R What is the correct way to specify this argument for Code::Blocks? 回答1: Whoever decided to make the token $ORIGIN is an evil bastard who deserves a special place in programmer hell. Since '$' is a special character for