object-files

Does every .h file have a corresponding object file?

若如初见. 提交于 2019-12-24 08:58:04
问题 I'm trying to write a makefile, but I don't really understand how object files work. There are no .o files in my folder, so how can I be compiling them? Does every .h file have a corresponding .o ? If not, then how do we know if we have to compile an object file or not? Sorry if these are stupid questions, I'm new to programming. Thank you. 回答1: Basically the header (.h) files tell the compiler that things exist when it's generating the object (.o) files. The compiler generates object files

How to list all externally-undefined symbols of a static library on Linux?

試著忘記壹切 提交于 2019-12-23 15:11:57
问题 I have a static library libfoo.a , which is just a compression of multiple .o files. I am looking for a way to list all symbols that appear in the static library as UND have no definition in this static library So that I can find out all external symbol dependencies of this library. 回答1: You can use this method: ld -r -o deleteme.o --whole-archive libfoo.a nm -C --undefined-only deleteme.o # `-C` if you might have C++ archive members rm deleteme.o Demo : one.c extern void two(void); void one(

symbol table and relocation table in object file

牧云@^-^@ 提交于 2019-12-20 10:44:27
问题 From what I understand, instructions and data in an object file all have addresses. First data item start at address 0 and first instruction also start at address 0. The relocation table contains information about instructions that need to be updated if the addresses in the file change, for example if the file is linked together with another. Line A, in the example below, would be in the relocation table. I don't think B would be in the relocation table, since the address of label "equal" is

How to put generated files (e.g. object files) into a separate folder when using Qt/qmake?

一个人想着一个人 提交于 2019-12-18 12:17:20
问题 I have a Qt project that uses qmake. To improve clarity and readability, I'd like to keep the source files build system generated files (such as object files) separate. So my first step was putting the source files into a src/ sub directory: myproject/ myproject.pro src/ main.cpp MainWindow.ui ... That way I separated the source files from the build system (*.pro). However, when I then run qmake followed by make , the generated files (object files, etc) are placed into the main project folder

Combining multiple .o files into an executable

女生的网名这么多〃 提交于 2019-12-12 00:13:03
问题 I'm trying to combine object files created from C++ files into an executable using gcc . Unfortunately, gcc is giving me thousands of undefined reference errors to strings, arrays, etc. I am doing this on a Windows machine, so no terminal commands; only cmd commands. I'm simply doing: gcc a.o b.o c.o -o prgm.exe What am I missing/doing wrong? EDIT: I recreated the .o files with g++ doing: g++ a.cpp -g -c -Wall -std=c++0x -lSDLmain -lSDL -lSDL_image -lSDL_ttf -IC:\SDL-1.2.14\include -o a.o ,

Trouble Linking object files from project in Tests

会有一股神秘感。 提交于 2019-12-11 07:35:34
问题 I am trying to link some of the object files so that I can write tests using UnitTest++ in the Codelite IDE. Mysteriously, the tutorial does not say how to use .o files from a (different) project. If I was using the command line, this thread shows me how to do that. However, I am having more difficulty in the Codelite editor. The accepted answer in this other thread says "[i]n the codelite's IDE, this is added in the linker's option textbox," however, I am not finding that to be the case. I

Disassemble Microsoft Visual Studio 2003 compiler output

為{幸葍}努か 提交于 2019-12-09 06:30:18
问题 I'm seeing what I think is strange behaviour from object files output by the Microsoft Visual Studio 2003 tools. The file utility tells me: asmfile.obj: 80386 COFF executable not stripped - version 30821 For objects created by the assembler, but for objects coming from C files, I get just: cfile.obj: data Using Microsoft's dumpbin utility and the objdump I got from cygwin, I can disassemble the assembly-built file, but I get no useful results from either utility for the C-built files. I have

My C++ object file is too big

て烟熏妆下的殇ゞ 提交于 2019-12-07 08:00:56
问题 I am working on a C++ program and the compiled object code from a single 1200-line file (which initializes a rather complex state machine) comes out to nearly a megabyte. What could be making the file so large? Is there a way I can find what takes space inside the object file? 回答1: There can be several reasons when object files are bigger than they have to be at minimum: statically including dependent libraries building with debug information building with profiling information creating

My C++ object file is too big

我的未来我决定 提交于 2019-12-05 17:29:09
I am working on a C++ program and the compiled object code from a single 1200-line file (which initializes a rather complex state machine) comes out to nearly a megabyte. What could be making the file so large? Is there a way I can find what takes space inside the object file? There can be several reasons when object files are bigger than they have to be at minimum: statically including dependent libraries building with debug information building with profiling information creating (extremely) complex data structures using templates (maybe recursive boost-structures) not turning on optimizing

It is possible to read an object file?

你离开我真会死。 提交于 2019-12-04 19:39:15
问题 I was curious about .obj files: I pretty much don't know what they are (or what they contain), so I opened them with Vim text editor and what I found inside was an Alien like language... Is there any way to understand what they represent and what is their content Also, for what are they being used ? Thanks. 回答1: Sure. But every different platform has a different object format. On Windows, you could use a tool like dumpbin (dumpbin comes with Visual Studio). On Linux, you could use "dumpobj",