Linked Questions

2 votes
1 answer
1k views

GCC Merge two differents object files to one object file [duplicate]

// f.for is a Fortran source file // c.c is a C source file # gfortran -c f.for // produce f.o # gcc -c c.c // produce c.o since f.for calls some functions from c.c....
  • 1,031
0 votes
1 answer
492 views

Creating object file from other dependent object files [duplicate]

my files dependencies a.c, a.h, b.c, b.h, c.c, c.h, are like that: // a.c #include "a.h" #include "b.h" #include "c.h" #include <lib> // b.c #include "b.h" #include <lib> // c.c #...
  • 607
1 vote
1 answer
184 views

Qt 5.2.0 generate single .o file [duplicate]

Now Qt generates one .o file per every .cpp file in my project. Can I force it to generate only one huge .o file? Or can I convert multiple .o files in a single one using some utils? Edit1: The ...
  • 500
21 votes
8 answers
36k views

Compile multiple C source fles into a unique object file

I have some C source files and I am using gcc. I basically want to compile all of them and create one single object file. When I try: gcc -c src1.c src2.c src3.c -o final.o I get: gcc: cannot ...
  • 15.8k
16 votes
5 answers
28k views

How to hide the exported symbols name within a shared library

For VC, I can write a DEF file and use the 'NONAME' directive to leaving only the ordinal number in dll's export table. How could I do the same thing with gcc and ELF format shared library? Or, is ...
  • 694
5 votes
3 answers
8k views

is it possible to create an object file from other object files in gcc?

I was trying to do something like this in a makefile: program.exe: ui.o main.o gcc ......etc ui.o: window1.o window2.o gcc -c window1.o window2.o -o ui.o #this doesn't want to work window1.o: ...
  • 37.1k
9 votes
4 answers
3k views

C/C++. Advantages of libraries over combined object files

While it is commonplace to combine multiple object files in a library, it is possible (at least in Linux) to combine multiple object files into another object file. (See combine two GCC compiled .o ...
  • 623
7 votes
2 answers
1k views

C: clarification on translation unit

If we have two .c files and a .h file: main.c sub.c sub.h, where main.c #include "sub.h" ... sub.c #include "sub.h" ... we can compile the program with, either i) gcc -o a.out main.c sub.c or ...
2 votes
2 answers
3k views

Order of objects in a static library

I have a C project using several object files that needs to be linked in a specific order to find all needed symbols. For example this command works fine (lib2.o depends on lib1.o etc.) gcc -o ...
  • 1,704
5 votes
2 answers
651 views

On Windows MSVC, is it possible to merge some .obj into one .obj? If yes, how should I do that?

For example, there is three object files a.obj b.obj c.obj just compiled out with cl, and it is desired to combine them into one combined.obj. A comment of an SO question points out that on *nix it's ...
1 vote
2 answers
491 views

Symbol not found __udivsi3

I compiled my one of the Contiki application (power-cons.c: which evaluate the power consumption of TelosB mote) as a Contiki executable (power-cons.ce). The Contiki executable is then uploaded to the ...
0 votes
1 answer
446 views

Making relocatable object with gcc causes "cannot find -lgcc_s" error

I'm trying to make a relocatable object file with gcc. I use solution from this post. The solution works fine with ld: $ ld -r a.o b.o -o c.o However when I try to use it with gcc, the following ...
  • 7,915
-1 votes
1 answer
311 views

How to link obj files without crt?

how to can i achieve linking 2 .o file without CRT. Compiling .c files: gcc -ffreestanding -c file.c -o file.o Linking: gcc file1.o file2.o -o f.o Flags -nostartfiles and -nostdlib don't help ...
1 vote
1 answer
224 views

Best practice to link modules split into multiple files with gcc/g++

I would like to have a file containing only the declarations in a module and one or more files containing the definitions. According to How to split a module into multiple files (and this awseome ...
  • 345
0 votes
1 answer
68 views

Do I need to specify an indirectly-used library to the compiler?

If a C program uses a library A (.a or .so), and the library A uses another library B (.a or .so), when I compile the C program, do I have to specify the path to the header and the library file of ...
user avatar