linker

LNK2019 - why unresolved external with template friend function

£可爱£侵袭症+ 提交于 2021-02-19 03:37:08
问题 I don't get this error: #include <iostream> using namespace std; // LNK2019f.cpp // LNK2019 expected template<class T> void f(T) {} template<class T> struct S { friend void f(T); // try the folowing line instead // friend void f<T>(T); }; int main() { S<int> s; int a = 2; f(a); // unresolved external } Taken from http://msdn.microsoft.com/en-us/library/799kze2z(v=vs.80).aspx Why does the error not show up if I comment out S< int > s ? I got that I need to declare the template argument list as

Linking with another start-up file

你说的曾经没有我的故事 提交于 2021-02-19 02:37:09
问题 I am trying to link a program with my own start-up file by using the STARTUP directive in a LD script: ... ENTRY(_start) STARTUP(my_crt1.o) ... GCC driver is used to link the program (not to bother with library paths like libgcc, etc.): gcc -T my_script.ld ... Unfortunately, it only works with a GCC compiled for powerpc targets, while arm or i686 targets don't and still include crt0.o in collect2. For example: arm-eabi-g++ -v -T my_script.ld ... gives me: collect2 ... /opt/lib/gcc/arm-eabi/4

compiling glibc from source with debug symbols

时间秒杀一切 提交于 2021-02-19 02:27:08
问题 I need to compile glibc from source with debug symbols . 1.Where do i specify the '-g' option for this 2.How do i later make a sample code link to this particular glibc rather than the one installed on my system? 回答1: I need to compile glibc from source with debug symbols You will have hard time compiling glibc without debug symbols. A default ./configure && make will have -g on compile line. How do i later make a sample code link to this particular glibc rather than the one installed on my

__attribute__((section(“name”))) usage?

我们两清 提交于 2021-02-18 00:49:09
问题 I have ran through code that use _ attribute _((section("name")). I understand that for gcc compiler this allows you to tell the linker to put the object created at a specific section "name" (with "name" absolute address declared in a linker file). What is the point of doing this instead of just using the .data section? 回答1: There are many possible uses. [Edit to add note: this is just a sample of uses I've seen myself or considered, not a complete list.] The Linux kernel, for instance, marks

Linking GLEW and others, _glViewport is the only unresolved

房东的猫 提交于 2021-02-16 21:12:32
问题 I'm using G++ to link my project to glew32, glfw, opengl32, glu32, etc, everything compiles fine - however at the link stage everything but glViewport links and I get this error: undefined reference to '_glViewport'. I find this... odd since everything else was fine and I'm kinda at a loss for what to do. I look forward to any advice on what to try and or do. 回答1: As per my comment, you need to link with the OpenGL libraries, when you compile do (Linux/cygwin) g++ -o target source.c -lGL To

GDAL Not Linking

别说谁变了你拦得住时间么 提交于 2021-02-16 20:11:13
问题 I'm trying to get my program running on Windows. It depends on GDAL, a library for loading GIS data. It compiles and links fine on both Linux and macOS. I'm using CMake with MinGW and I'm running into linking errors like this: undefined reference to `GDALRasterBand::RasterIO(GDALRWFlag, int, int, int, int, void*, int, int, GDALDataType, long, long, GDALRasterIOExtraArg*)' CMakeFiles\Routes.dir/objects.a(elevation.cpp.obj): In function `ZN13ElevationData9calcStatsEv': C:/Users/Logan/Documents

Creating a Delphi IoC. How to disable Delphi's linker from removing unused classes

[亡魂溺海] 提交于 2021-02-16 16:23:06
问题 I've created a IoC in delphi with the ability to automatically register any classes that have a IocSingletonAttribute to it. The AutoRegister looks like the following. procedure TIocContainer.AutoRegister; var ctx: TRttiContext; rType: TRttiType; attr: TCustomAttribute; &Type: PTypeInfo; begin ctx := TRttiContext.Create; for rType in ctx.GetTypes do Begin for attr in rType.GetAttributes do Begin if TypeInfo(IocSingletonAttribute) = attr.ClassInfo then Begin &Type := IocSingletonAttribute(attr

linkage error:multiple definitions of global variables

为君一笑 提交于 2021-02-11 14:24:42
问题 I am using gcc for compiling a number of .c files. Lets say following is the case: C files are: main.c tree.c header file is: tree.h I have declared some golbal variables in tree.h . Lets say following is the global varible with value assigned: int fanout = 5; Earlier I had kept main() function in tree.c file. And there was no problem in linking. But now i want to keep the main function separate . I just moved the main function in the newly created .c file. Now the problem is, it shows the

Linker error while implementing pimpl idiom

不羁岁月 提交于 2021-02-11 13:10:44
问题 Edited to provider a little more clarity. Apologies for confusing everyone. This is under Windows. I have a static library that implements a class using the pimpl idiom. The pimpl header is not only used by the consuming code but it also links against the static library. Yet, when I compile the consuming code (.exe), the linker complains about unresolved externals on the implementation class that the pimpl header supposedly hides. How can this be possible? // Foo.lib // Foo.h class FooImpl;

Linker error while implementing pimpl idiom

穿精又带淫゛_ 提交于 2021-02-11 13:07:56
问题 Edited to provider a little more clarity. Apologies for confusing everyone. This is under Windows. I have a static library that implements a class using the pimpl idiom. The pimpl header is not only used by the consuming code but it also links against the static library. Yet, when I compile the consuming code (.exe), the linker complains about unresolved externals on the implementation class that the pimpl header supposedly hides. How can this be possible? // Foo.lib // Foo.h class FooImpl;