linker

Embedding linker dependencies in an object file?

Let's say I have a source file, say helper.c, which gets compiled into an object library (helper.a). Now, this uses functionality from many system libraries, so currently when I want to link helper.a into an executable, I end up having to list all the dependencies: gcc main.c helper.a -o my_app -lrt -lpthreads ... What's the common ap...

Function template in a namespace in a separate file compiles fine, but the linker cannot find it

This problem is in defining and declaring a function template in a namespace that is defined in an external file from where the function is instantiated. Here's the smallest reproducible example I could come up with. 4 files follow: The function template declaration in a named namespace: // bar.h #include <algorithm> namespace barspac...

Linking an executable

I'm trying to figure out how to manually link an ELF file. I am aware of the file structure, but how do I determine the order in which the relocatable objects are to be linked? ...

Make Xcode tell the compiler to not link to any library including the standard library?

Well, the title says it all: How can I make Xcode tell the compiler not to link? I am making a library which may not link to anything. Where can I set in the target's properties that it must not link to the standard library, as I can choose static or dynamic only, there is no not option. Can you help me, please? Thanks. ...

Reasons to choose C over C++

Possible Duplicate: Whats the advantage of using C over C++ or is there one? Hello all. I was wondering why so many people continue to code in C when C++ has now been out for such a long time. What advantages/disadvantages are there?? I heard that there are differences (ie. advantages to C) in the way that linking is done, b...

Explaining readelf -S output

I'm trying to load an elf file into a MIPS simulator I made. The problem I'm having is that I don't quite understand the meaning behind the elf section header offset. When I do a segment dump, segments 25 - 31 and 33 - 35 "start" at 0x00000000 but the header states that the segment starts at an offset of some value (ex. 010190). Also ...

Somehow I'm violating the one definition rule

I am getting errors with the linker such as: osd.o(.ndata+0x514):C:\Documents and Settings\Thomas\My Documents\PIC\dsPIC33FJ128GP802\On Screen Display\osd.c: multiple definition of `video_buff_vis_num' main.o(.ndata+0x0):C:\Documents and Settings\Thomas\My Documents\PIC\dsPIC33FJ128GP802\On Screen Display\main.c: first defined here osd....

Compile a Standalone Static Executable

I'm trying to compile an executable (ELF file) that does not use a dynamic loader. I built a cross compiler that compiles mips from linux to be used on a simulator I made. I asserted the flag -static-libgcc on compilation of my hello.cpp file (hello world program). Apparently this is not enough though. Because there is still a segmen...

linker and loader reference

I'd like to read some text about the compile-link-load process of a executable. In general web-texts I found are not so detailed oriented as I'd like. And no... I'm sure a book about compilers&linkers,etc it would be too much. I want a general knowledge especially how things are in practice. Any reference would be appreciated... I'm su...

With Visual C++ Express 2008, the LIB environment variable is being ignored.

We are using LDRA to unit test our source code. In our case LDRA is using cl.exe and link.exe from VC++ express 2008, on several machines setting the LIB environment variable allows link.exe to find the libraries we specify, some machines ignore the LIB environment variable. Does anyone know what would cause the LIB environment variable ...

preventing "ld -wrap " circular references

I am using GNU ld's "-wrap" option to intercept calls in applications, but have ran into a scenario where the code implementing the wrapper indirectly calls the wrapped function, creating a circular reference. Example The goal is to wrap read calls that occur in Program Foo. This code can be recompiled/relinked, but not modified. Prog...

Missing crt1 and crti when crosscompiling

Hey I'am trying to build a cross compile toolchain based on GCC4.5 and newlib with gold and link-time-optimization enabled. GCC compiles fine but it did not generate the crt1.o or crti.o files. Therefore when I tries to use the compiler for building Newlib it complains with the message: ld: error: cannot open crti.o: No such file or di...

Removing Code Linking for Different Targets in XCode - iAds

I have an app I am working on which has been split into two targets, one for the iPhone and one for the iPad. The iPhone side (w/iAds) runs perfectly, but the iPad target gives me errors. It basically boils down to the iPad target not recognizing the iAd framework. I've tried weak linking but I still get iAd/iAd.h: No such file or dire...

Basic CMake Question - Linking Fails

I'm configuring my project for CMake and am having linking problems - the project files all compile successfully, then it says it is linking and reports all sorts of symbols not found. These symbols are mostly provided by my own code, while some of them are provided by BerkeleyDB, which is being properly located and included. Here is...

How can I get my very large program to link?

Our next product has grown too large to link on a machine running 32-bit Windows. The sum total of all the lib files exceeds 2Gb and can only be linked on a 64-bit Windows machine. Eventually we will exceed that boundary, since our software tends to grow rather than contract and we are using a 32-bit linker (MS Visual Studio 2005): we ...

Compiling kernel to a binary file on mac

I was following these tutorials to make a simple kernel that I would then load using GRUB. The instructions for compiling didn't work (ld couldn't find the -T option) and when I finally got a compiled file it was in Macho format. What are the correct steps to take when compiling these files on Mac. Edit: I compiled the code on an Ubuntu ...

C++ link error on Visual Studio 2010 x64

I'm upgrading a C++ code base from VS2005 to VS2010 and I'm rebuilding some third party C++ dependencies. I have no problem building these 32-bit but keep running into problems linking 64-bit (x64). I'm getting unresolved externals for a number of standard library functions. For example: error LNK2001: unresolved external symbol "__decl...

Mix GFortran/MSVC objects when linking: undefined reference to _chkstk

Trying to compile Xfoil and plotlib The fortran files are compiled with MinGW gfortran 4.5.0, and I compiled W32win.c with MSVC (2008/15.00). During linking with GCC I receive error: ../plotlib/libPlt.a(W32win.o):(.text+0x1469): undefined reference to `_chkstk' ../plotlib/libPlt.a(W32win.o):(.text+0x1509): undefined reference to `_c...

CMake link stage question

I am currently building a rather large application, using cmake to generate cross platform build scripts. During this process of putting together the cmake build scripts, I have discovered the pain of gcc link line ordering. The basic issues is that including static libraries in the wrong order leads to unused library symbols being thro...

What's the difference between hard and soft floating point numbers?

When I compile C code with my cross toolchain, the linker prints pages of warnings saying that my executable uses hard floats but my libc uses soft floats. What's the difference? ...