linker

Why does an assembly program only work when linked with crt1.o crti.o and crtn.o?

隐身守侯 提交于 2020-02-13 04:57:56
问题 I like to know how programs work so to make it as bare bones as possible I fool around with assembly. I just found out how to assemble code for x86_64 using wprintf function (found out wide chars are 32 bit). all I had to do was link to libc (-lc). I'm trying to assemble code for 32-bit doing about the same thing but I stumbled quite a bit. Eventually I used gcc to do the linking ( and changed the _start: to main:). So then I did the linking myself using ld and included crt1.o crti.o and crtn

Overhead in unused code

本小妞迷上赌 提交于 2020-02-13 04:35:09
问题 I am wondering what the overhead is of having unused functions in your code. Say for example you have some debug logging, and you then give most of your objects a ToString() function that is being used in the debug logs. In a release build that debug logging is not being used. Is it then worth it removing the source code of those ToString() functions? (e.g. via Macro?) Or do they just make the executable marginally larger and otherwise don't impact performance? e.g. no speed impact? Or does

How to fix a linker error with PKEY_Device_FriendlyName

痞子三分冷 提交于 2020-02-12 05:01:05
问题 Upon using PKEY_Device_FriendlyName, I'm getting the following errors: Error 1 error LNK2001: unresolved external symbol _PKEY_Device_FriendlyName DefaultAudioDeviceCPP.obj Error 2 fatal error LNK1120: 1 unresolved externals C:\Users\srobertson\Documents\Visual Studio 2005\Projects\DefaultAudioDeviceCPP\Debug\DefaultAudioDeviceCPP.exe What's a very simple way to clear these errors? I'm including functiondiscovery.h and functiondiscoverykeys.h. Also the path in Project->Properties...-

Undefined symbols for architecture x86_64 buiding on Netbeans

醉酒当歌 提交于 2020-02-08 06:35:13
问题 I am trying to create a simple Fix client-server using QuickFix and I have tried to implement QuickFix.Application interface. During the building I have faced this problem : "Undefined symbols for architecture x86_64" and despite I have already read all the relative answers to this question and trying everything suggested I have still the above issue. I am using Netbeans and C++, and this is the error I got g++ -o dist/Debug/GNU-MacOSX/fix_engine_server build/Debug/GNU-MacOSX/Application.o

How to link with libstdc++_pic.a with GCC?

喜夏-厌秋 提交于 2020-02-06 11:27:37
问题 I have a libstdc++_pic.a on my system (Ubuntu 12.04, gcc 4.6.3), presumably this is the version of libstdc++ created with -fPIC. I also have a libstdc++.a. I see the following error when I try to statically link libstdc++ with a shared library via the -static-libstdc++ link flag: :-1: error: /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a(functexcept.o): relocation R_X86_64_32 against `std::bad_exception::~bad_exception()' can not be used when making a shared object; recompile with -fPIC So I'm

How to link with libstdc++_pic.a with GCC?

前提是你 提交于 2020-02-06 11:22:09
问题 I have a libstdc++_pic.a on my system (Ubuntu 12.04, gcc 4.6.3), presumably this is the version of libstdc++ created with -fPIC. I also have a libstdc++.a. I see the following error when I try to statically link libstdc++ with a shared library via the -static-libstdc++ link flag: :-1: error: /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a(functexcept.o): relocation R_X86_64_32 against `std::bad_exception::~bad_exception()' can not be used when making a shared object; recompile with -fPIC So I'm

clang: export symbols of implicitly instantiated functions with O3

假装没事ソ 提交于 2020-02-06 05:08:05
问题 TL,DR: How can I force clang to export the symbols of implicitly instantiated functions even when -O3 is active? Let's take the following code: #include <iostream> #include <llvm/Support/DynamicLibrary.h> #include <llvm/ExecutionEngine/ExecutionEngine.h> #include <llvm/ExecutionEngine/RTDyldMemoryManager.h> template <typename T> __attribute__((noinline)) int twice(const T& t) { return t * 2; } int thrice(const int& t) { return t * 3; } int main() { std::cout << twice(5) << std::endl; std:

Linker errors with codelite, unittest++ and g++ on linux

北城余情 提交于 2020-02-04 05:20:29
问题 I'm new to unit testing in c++, and writing c++ on Linux (Mint). I'm using CodeLite as my IDE. I have found several answers on stackoverflow about linker errors, but after hours of trying various solutions I have not succeeded in implementing a solution correctly. I installed unittest++ through apt-get. The unittest++ header files were installed in /usr/include, so I added this to the Compiler linker options in Codelite (Right click project name->Settings, Compiler): Codelite screenshot I

Rename a function without changing its references

为君一笑 提交于 2020-02-04 05:19:06
问题 I have an object file compiled using gcc with -ffunction-sections option. I have access to the source file but iam not allowed to modify it. file.c void foo(void) { bar(); } void bar(void) { abc(); } What iam trying to achieve is to make all the references to bar take an absolute address(which I'll assign in the linker script) whereas bar will be placed at some other address by the linker. A possible solution is to rename bar to file_bar without changing the call to bar inside foo(). I tried

Installing OpenCV in Visual Studio 2012

杀马特。学长 韩版系。学妹 提交于 2020-02-03 10:38:50
问题 Im trying to install OpenCV to work with Visual Studio. I'm using the 2012Pro version but I think it should be the same as vs10. I was following this tutorial: http://docs.opencv.org/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html#windows-visual-studio-how-to I have A Solution with only one Project And with only one file. For testing purposes I used the same code as in the tutorial. // Video Image PSNR and SSIM #include <iostream> // for standard I/O