linker

Declaring class objects in a header file

妖精的绣舞 提交于 2019-12-19 07:22:09
问题 Greetings everyone. I seem to be snagging on a fundimental but I cant find the solution anywhere. Anywho, will go ahead and explain. I have a program consisting of three files; main.ccp, add.h, add.cpp. I declare the class 'SA' in add.h and have all my functions defined in add.cpp additional.h class SA { ... public int x; } Obj1, Obj2; main.ccp #include "additional.h" int main() { Obj1.x = 5; ... } This gives me a link error on compiling: error LNK2005: "class SA Obj1" (?Obj1@@3VSA@@A)

Compiling a custom malloc

两盒软妹~` 提交于 2019-12-19 06:56:44
问题 I have written a custom library which implements malloc/calloc/realloc/free using the standard C prototypes, and I figured out how to compile it to an so. I want to test the library by linking a standard application against it? What would be a good way to do this? Once I have a working library I assume I can just load it with LD_PRELOAD, but how do I get my functions to co-exist with but take precedence over the system library ones? My functions need to make a call to malloc in order to get

Linking to Python import library in Visual Studio 2005

て烟熏妆下的殇ゞ 提交于 2019-12-19 06:03:16
问题 I have a C++ application that has embedded Python. I'm building with Visual Studio 2005. When I try to link to python26.lib, I get a number of unresolved symbols, all of which begin with "__imp": error LNK2019: unresolved external symbol __imp__Py_Initialize referenced in function _main python26.lib is an import library (installed by the Python 2.6 installer). What do I have to do to resolve these symbols? They do exist in the import library (dumpbin /all shows them). Thanks. 回答1: Looks like

What are the drawbacks of single source project structures?

社会主义新天地 提交于 2019-12-19 05:43:58
问题 I'm new in my current company and working on a project written by my direct team lead. The company usually doesn't work with C++ but there is productive code written by my coworker in C/C++. It's just us who know how to code in C++ (me and my lead, so no 3rd opinion that can be involved). After I got enough insight of the project I realized the whole structure is... special . It actually consist of a single compilation unit where the makefile lists as only source the main.hpp . This

What are the drawbacks of single source project structures?

泄露秘密 提交于 2019-12-19 05:43:27
问题 I'm new in my current company and working on a project written by my direct team lead. The company usually doesn't work with C++ but there is productive code written by my coworker in C/C++. It's just us who know how to code in C++ (me and my lead, so no 3rd opinion that can be involved). After I got enough insight of the project I realized the whole structure is... special . It actually consist of a single compilation unit where the makefile lists as only source the main.hpp . This

When i should use ld instead of gcc?

☆樱花仙子☆ 提交于 2019-12-19 05:38:07
问题 I want to know when i should use ld linker instead off gcc. I just wrote a simply hello world in c++, of course i include iostream library. If i want make a binary file with gcc i just use: g++ hello hello.cpp and i've got my binary file. Later i try to use ld linker. To get object file i use: g++ -c hello.cpp . Ok that was easy, but the link command was horrible long: ld -o hello.out hello.o \ -L /usr/lib/gcc/x86_64-linux-gnu/4.8.4/ \ /usr/lib/gcc/x86_64-linux-gnu/4.8.4/crtbegin.o \ /usr/lib

Haskell ghc compiling/linking error, not creating executable. (linux)

耗尽温柔 提交于 2019-12-19 05:08:58
问题 I wrote a basic hello world program in haskel and tried to compile it with: ghc filename.hs. It produces .hi and .o files but no executable and displays this error in the linker: marox@IT-marox:~/Marox$ ghc tupel.hs Linking tupel ... /usr/bin/ld: --hash-size=31: unknown option /usr/bin/ld: use the --help option for usage information collect2: ld returned 1 exit status Googling didn't return any useful information. I am on ubuntu 12.04. How can I fix this? 回答1: Have you binutils-gold installed

LLVM insert pthread function calls into IR

↘锁芯ラ 提交于 2019-12-19 04:12:25
问题 I'm writing a LLVM pass (it's a LoopPass ) that needs to insert pthread functions calls like pthread_create() and pthread_join() into the IR. I know how to create and insert a function call into IR, but I am having trouble to get the pthread representation of Function* in LLVM. Here's what I have: Function *pthread_create_func = currentModule->getFunction("pthread_create"); but it returns NULL. As a comparison Function *printf_func = currentModule->getFunction("printf"); will return the

FreeType library and “Undefined reference to FT_Init_FreeType”

為{幸葍}努か 提交于 2019-12-19 04:05:14
问题 Coming from PHP, this is my first experience with C/C++ (so go easy on me). I'm following this tutorial to write a simple script using the FreeType library. The following compiles just fine: #include <ft2build.h> #include FT_FREETYPE_H main() { FT_Library library; FT_Face face; } This tells me that the FreeType library is readily available to the compiler. However, things break once I try to use any methods. For example, take the following script: #include <ft2build.h> #include FT_FREETYPE_H

How do I determine if an EXE (or DLL) participate in ASLR, i.e. is relocatable?

我们两清 提交于 2019-12-19 03:59:46
问题 How do I determine if an EXE (or DLL) participate in ASLR, i.e. is relocatable? I want to check some EXE's on my system whether they are relocatable and participate in ASLR. I know the default behavior of the linker is to strip base relocations, so that the EXE is not relocatable? How do I see from a tool like FileAlyzer whether the image participate in ASLR? 回答1: A relocatable module (exe or dll) doesn't necessarily need to have ASLR enabled but a module that has ASLR enabled needs to be