linker

linker error: undefined reference c++

I've tried looking at similar problems, but could not easily find one that helped my problem. I've created a project in C++ and am working on UNIX to compile, link, and run it. My specific problem is an undefined reference to a method I declare in a separate file. In the file SharedCache.cpp, I have the following method: int SharedCac...

Use both static and dynamically linked libraries in gcc

I need to distribute a binary that will run on as many x86 Linux distributions as possible. That means that I have to statically link some libraries, like glibc, because the user might not have the version I use. Other libraries have to be dynamically linked, like fontconfig, because it relies on a cache file format and hard coded locati...

"LNK2022: metadata operation failed" driving me insane

I have a big solution with lots of projects, using VS2008 SP1, and at least once a day I encounter the LNK2022 error. If I do a full rebuild of the solution it builds fine, but this is not fun. It happens when a dependent DLL is changed 'insignificantly' (i.e. without changing any methods or classes), and the referencing project is late...

Undefined Symbol when compiled with -O2 only on Mac

I'm working on a library that must compile on linux and mac os X. Until now, I had no problem, compiling with "-g" worked well under both OS. I tried to compile with some optimization ("-O2") and it works well under linux but I get an Undefined Symbol when I try to link a program with my library under mac os X. Does anyone have any clu...

How do you link to a specific version of a shared library in GCC

I'm compiling some code which uses libcurl on a Debian Linux system. My dev machine is running Debian 5 but I want the binary to be usable on older Debian 4 systems too. I find that if I specify -lcurl it will link to libcurl.so.4 but Debian 4 systems only have libcurl.so.3 Is there some way I can tell GCC to link to either libcurl.so....

Ignoring files when merging metadata during the linking process in VS2005

Hello, I'm trying to get my project to compile with the common language runtime, and I'm suddenly running into the following linking errors, when I attempt to make a debug build: ============================================================================== Main.obj : error LNK2022: metadata operation failed (8013118D) : Inconsistent ...

Unresolved external symbol link error

i have a project where i need mouse hooks to be used, so i have added a MOUSE HOOK DLL project to my solution...on rebuild..i am getting the follwoing errors Error 3 error LNK2005: "struct HHOOK__ * MyHook" (?MyHook@@3PAUHHOOK__@@A) already defined in projdialog.obj projdialogDlg.obj Error 4 error LNK2005: "struct HINSTA...

How to static link on OS X

I'm trying to link to a static library on OS X. I used the -static flag in the gcc command but I an error message: ld_classic: can't locate file for: -lcrt0.o collect2: ld returned 1 exit status I looked in the man pages and it reads something like: This option will not work on Mac OS X unless all libraries (including libgcc.a) ...

initializng a C array with repetitive data

I would like to initialize an array of structs, with the same element repetitively, ie struct st ar[] = { {1,2}, {1,2}, {1,2} }; However I do NOT want to run any code for that, I wish that the layout of the memory upon program's execution would be like so, without any CPU instructions involved (it would increase boot time on very slow...

Linking error with g++ 3.4.4 and g++ 3.4.5

Using: windows xp, g++ 3.4.4 with cygwin and g++ 3.4.5 with mingw. I'm compiling a simple unit test class with cppunit. When I link using g++ 3.4.5 I get a lot of linking errors. When I link with g++ 3.4.4 I don't get any errors and the exe links fine and runs. I can't seem to trace down the errors, so any thoughts? Thanks. ED...

error LNK2019: unresolved external symbol Visual C++

I've got this MFC application i'm working on that needs to have an embedded database. so, i went on hunting for a slick,fast "embeddable" db 4 it and stumbled accross SQLite. now, i've created a DB with it, and i created a static library project with VS2k8.the library project will be used in another main project . in the library projec...

Compiling with DMD on 64bit Linux or Linking with 32bit object files

What is the best way to compile programs with DMD on a 64bit machine? It doesn't need to compile to 64Bit code. I know about GDC, but want to work with D2 also. There is also chroot, but am hoping for a simpler way. The actual problem isn't with compiling, but linking. DMD calls on GCC to perform linking with system libraries. Could I g...

What do these linking errors mean? (C++) (MSVC++)

EDIT: When I merge link_def.cpp with link_dec.h, I only get the first error, not the second two. I got these linker errors when I tried to compile some code: CODE: #include"list_dec.h" #include"catch.h" int main() { list<int, 100> L1; try { L1.return_current(); } catch(err) { return -1; } ret...

Ignore #pragma comment(lib, ...) ?

I'm attempting to perform a link of previously generated .obj files (using the latest version of MSVC). When those .obj's were created, the source code specified: #pragma comment(lib, ...) As such, the linker is attempting to link against static libraries specified in the source. Is there a way to instruct the linker to ignore these...

GCC is not linking library to a non-default path!

I have boost C++ libraries already installed on my Fedora10 machine but I want to use a newer version that I keep at some location in my home folder. I want g++ to use include and library files from my home folder location instead of default (/usr/include and /usr/lib64). For that matter, I also have declared CPLUS_INCLUDE_PATH and LIBR...

Gurus say that LD_LIBRARY_PATH is bad - what's the alternative?

Hi. I read some articles about problems in using the LD_LIBRARY_PATH, even as a part of a wrapper script: http://linuxmafia.com/faq/Admin/ld-lib-path.html http://blogs.sun.com/ali/entry/avoiding_ld_library_path_the In this case - what are the recommended alternatives? Thanks. ...

Any downsides to using statically linked applications on Linux?

Hi. I seen several discussions here on the subject, but wanted to ask about my particular situation: If I have some 3rd part libraries which my application is using, and I'd like to link them together in order to save myself the hassle in LD_LIBRARY, etc., is there any downside to it on Linux, other then larger file size? Also, is it ...

Using AssemblyBuilder, how can I make all or any of the referenced assemblies embedded instead of linked in the saved assembly?

I have an executing assembly, which generates another assembly dynamically using AssemblyBuilder. The generated assembly consists of functions which simply test the construction of certain classes in the executing assembly. Since the functions in the generated assembly reference classes in the executing assembly, I want to have the exe...

"file not recognized" while using the GNU linker

I'm probably doing something wrong, being a newbie. Could you please help me out? I've written a simple Hello World program in C called hello.c, and ran the following command: gcc -S hello.c That produced hello.s. Then I used that file with GNU assembler, as: as hello.s Which produced a non-executable a.out, which still needs to b...

How do you link a .lib file without putting them into the compilers library folder?

Is there a way in my code that I can link to the library files I need so that I do not have to setup each individual compiler I use? I want to be able to use Visual C++.net 2005, G++, etc. I am trying to make a cross platform game engine, but some platforms use a custom compiler and I want to make my engine as versatile as possible. ...