Tag Info

Hot answers tagged

8

If fdisk is just an example and your goal is really to make static executables from dynamic executables, try Elf statifier. There's even a comparison with Ermine (by the Ermine vendor, so caveat (non-)emptor). Note that If you have many executables, their combined size is likely to be more than the combined size of the dynamically-linked executables plus ...


7

The start address is the address of main(), right? Not really: The start of a program isn't really main(). By default, GCC will produce executables whose start address corresponds to the _start symbol. You can see that by doing a objdump --disassemble Q1. Here's the output on a simple program of mine that only does return 0; in main(): 0000000000400e30 ...


5

Well of course it won't, because you won't have a C library anymore. All prelink does is to try and calculate an optimal load address for each library so that no program will have overlapping libraries, then update the libraries so that they default to loading at that address. Then when a program is run the libraries it uses are unlikely to need to be ...


5

The main entry point is God. Be it a C or C++ source file, it is the center of the application. Only in the same way that nitrogen is the center of a pine tree. It is where everything starts, but there's nothing about C or C++ that makes you put the "center" of your application in main(). A great many C and C++ programs are built on an event loop or an ...


2

glib is not your problem. This is: re.c:(.text+0xd6): undefined reference to `print_uppercase_words' What it's saying is you're calling a function print_uppercase_words, but it can't find it. And there's a reason. Look very closely. There's a typo: void print_upppercase_words(const gchar *string) After you fix that, you might still have a problem ...


2

What exact command do you use to build executable of your program? You need to tell g++ about additional directories with project-specific headers and libraries. If you have libcurlcpp.a copied into $proj_home/lib and libcurlcpp.h copied into $proj_home/hdr this will be something like: $ g++ your_program.cpp -Ihdr -Llib -lcurlcpp -static -o ...


2

Your bash functions should work, but the "usual" way of doing that is to write a wrapper script for each executable, and set anything that needs to be set in there. (You can change the executable name to foo.bin for instance, and call the wrapper script foo to make it easy to call.) For ELF targets (not sure about other object formats), you can also set the ...


1

I can't say I understand what a "statically linked dynamic library", nor do I know anything about signatures contained in libraries (sounds interesting though: does this mean the linker is able to check for type mismatches in arguments and return types at link time? ELF definitely does not have such a feature.) so this answer will not be from a comparative ...


1

I get the impression that if the function at the top of the list references "glib" or "gobject", you have Bad Issues(TM) with libraries that usually shouldn't go wrong. You get the wrong impression, if you mean this indicates the flaw is probably in those libraries. It doesn't mean that; it more likely means that's where an earlier mistake finally blew ...


1

To link with a library with a filename libad.a you link options to gcc should be: gcc abc.c -lad So you don't specify the extension, nor the starting lib part of the library file name. The output file will be a.out. You can specify extra search paths for the library with -L: gcc abc.c -L path_to_directory -lad


1

No, you can't do that. There's no gcc pragma for compile in this way. The most similar is the Microsoft Visual C++ #pragma comment(lib, …) or #pragma comment(linker, …) [1] [2] for noting that some libraries should be included in the link procedure. Hi, GCC. How are you doing? In case you forgot, this source file you're looking at right now is written ...


1

gcc will compile C and C and C++ as C++ simply as a result of you naming the files appropriately, the preprocessor doesn't come into that. You'll need extern "C" blocks around your C declarations in your C++ files to make sure the linker can link stuff correctly, though. But what you're describing is almost never going to be helpful. If you're using a ...


1

I was able to solve this with the help of the comments, particular credit to @Mat. Since I wanted to compile the openmpi version, it helped to use mpif90 instead of gfortran, which, on my system, is $ mpif90 --showme /usr/bin/gfortran -I/usr/include -pthread -I/usr/lib/openmpi -L/usr/lib/openmpi -lmpi_f90 -lmpi_f77 -lmpi -ldl -lhwloc



Only top voted, non community-wiki answers of a minimum length are eligible