linker-errors

Weak symbol link on Mac OS X

萝らか妹 提交于 2019-12-05 01:59:00
Currently I encountered a weak link issue on Mac OS X 10.6.7 with Xcode 4.0.2. robin@chameleon:/tmp/o$ gcc --version i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3) As the document http://developer.apple.com/library/mac/#technotes/tn2064/_index.html said, we can use gcc attribute ((weak_import)) for weak link symbol. However, the following sample code always throw compile error. As the following: weak.c : #include <stdlib.h> #include <stdio.h> extern int SayHello() __attribute__((weak)); int main() { int result; if (SayHello!=NULL) { printf("SayHello is present!\n");

Pure Virtual Function call from Base Ctor

孤街醉人 提交于 2019-12-05 01:45:23
问题 Consider the following sample code: #include <iostream> using namespace std; class base { public: base() { bar(); //Line1 this->bar(); //Line2 base *bptr = this; bptr->bar(); //Line3 ((base*)(this))->bar(); //Line4 } virtual void bar() = 0; }; class derived: base { public: void bar() { cout << "vfunc in derived class\n"; } }; int main() { derived d; } The above code has pure virtual function bar() in base class which is overriden in the derived class. The pure virtual function bar() has no

ld: undefined reference to symbol 'log2@@GLIBC_2.2.5'

左心房为你撑大大i 提交于 2019-12-04 16:41:52
问题 Whats wrong with for (level = 1; level <= log2((double)size); level++) ^ Seems like its from using log2() but whats wrong? I am using it with OpenMPI code actually, but commenting this line fixes things. Full Source(http://pastie.org/7559178) see line 40 [jiewmeng@JM Assign3]$ mpicc -o cpi cpi.c && mpirun -np 16 cpi /usr/bin/ld: /tmp/cca9x4he.o: undefined reference to symbol 'log2@@GLIBC_2.2.5' /usr/bin/ld: note: 'log2@@GLIBC_2.2.5' is defined in DSO /usr/lib/libm.so.6 so try adding it to the

'LIBCMT' conflicts with use of other libs + unresolved external symbols

自作多情 提交于 2019-12-04 16:09:21
问题 I have a program using OpenGL 3.2(+libs) and FreeType2. Then an other program with Boost and OpenSSL. The OpenGL side was to make sure text could be rendered and the boost/openssl program is to do a secure login/game server. Both programs work fine by them selfs. However adding Boost and OpenSSL to the game(GL + freetype) project caused it to fail to link. I have linked the following libs as well as including there includes folder. glimg.lib glutil.lib glfw.lib opengl32.lib freetype.lib

LNK2028 Managed C++ DLL calling function in another Managed C++ DLL

时光毁灭记忆、已成空白 提交于 2019-12-04 15:54:02
I'm using VS2010 with a managed C++ DLL calling a function in another managed C++ DLL and I'm getting many LNK2028 link errors that look like this. 1>udpPkt.obj : error LNK2028: unresolved token (0A0000AA) "unsigned short __cdecl ComputeCrc16(void const *,unsigned int)" (?ComputeCrc16@@$$FYAGPBXI@Z) referenced in function "public: short __thiscall CPrivateUdpPkt::ComputeCrc(void)const " (?ComputeCrc@CPrivateUdpPkt@@$$FQBEFXZ) When I use dumpbin /export on the called DLL I see the unresolved function listed as: 7 6 00001040 ?ComputeCrc16@@YAGPBXI@Z = ?ComputeCrc16@@YAGPBXI@Z ( unsigned short _

Linking… LINK : fatal error LNK1181: cannot open input file 'libgsl.a'

≡放荡痞女 提交于 2019-12-04 15:34:06
I am using SIFT algorithm code by Rob Hess which uses OpenCV library, in Windows. And I am having visual studio 2008 as the IDE. When I run the program for image matching having Debug as the Solution Configuration in VS There is no problem, everything works fine. But when i change the Solution Configuration to Release it gives a linking error. The error is: Linking... LINK : fatal error LNK1181: cannot open input file 'libgsl.a' Can someone explain me the reason and tell me how to resolve this. Thank you Finally found it Yes I was missing some libraries. libgsl.a comes in GnuWin32 gsl package.

Using GNU Scientific Library (GSL) under Windows x64 with MinGW

折月煮酒 提交于 2019-12-04 09:37:21
问题 I have installed MinGW and MSYS on Microsoft Windows (64bit), inside directory C:\MinGW (MSYS directory is C:\MinGW\msys\1.0 ). I have downloaded the latest GNU Scientific Library ( GNU GSL ) package from the official ftp. I have used MSYS to perform configure and make successfully as described in the INSTALL file in the GSL package. That means, in the MSYS command-line interface, in the MSYS home directory, I have inserted: $ ./configure $ make $ make install This produces a local directory

Why doesn't this “undefined extern variable” result in a linker error in C++17?

对着背影说爱祢 提交于 2019-12-04 08:47:57
问题 I have compiled and ran the following program in a C++17 compiler (Coliru). In the program, I declared an extern variable, but did not define it. However, the compiler doesn't give a linker error . #include <iostream> extern int i; // Only declaration int func() { if constexpr (true) return 0; else if (i) return i; else return -1; } int main() { int ret = func(); std::cout<<"Ret : "<<ret<<std::endl; } Why doesn't the compiler give a linker error? 回答1: Because the variable isn't odr-used. You

How to link C++ object files with ld

别说谁变了你拦得住时间么 提交于 2019-12-04 08:14:32
问题 I'm trying to link the output of C++ using ld and not g++. I'm only doing this to learn how to do it, not for practical purposes, so please don't suggest just to do it with g++. Looking at this question, the person gets the same error when they run the ld command: $ ld test.o -o test.out ld: warning: cannot find entry symbol _start; defaulting to 00000000004000e8 test.o: In function `main': test.cpp:(.text+0x1c): undefined reference to `strcasecmp' test.cpp:(.text+0x23): undefined reference

VC++ Calling a function of /clr project from a function of non /clr project within a solution

余生长醉 提交于 2019-12-04 07:53:57
I referred this somewhat similar question before asking this, but unable to solve my problem I am looking at an old application with many solutions. The problem is happening in one of the solutions (say S). Here is the situation: A project (say P1) inside S has all C/C++ files and needs to call a C# function Since P1 also contains .c files, I can't use /clr option with that If I compile the .c files in P1 as .cpp files then it generates lots of errors, I don't intend to change the source in that legacy .c file So I created another project (say P2) with /clr enabled and created one header file