linker-errors

How can I avoid the LNK2005 linker error for variables defined in a header file?

白昼怎懂夜的黑 提交于 2019-11-28 04:07:12
问题 I have 3 cpp files that look like this #include "Variables.h" void AppMain() { //Stuff... } They all use the same variables inside them so they have the same headers but I get stuff like this 1>OnTimer.obj : error LNK2005: "int slider" (?slider@@3HA) already defined in AppMain.obj Why is that? 回答1: Keep in mind that a #include is roughly like cutting and pasting the included file inside the source file that includes it (this is a rough analogy, but you get the point). That means if you have:

linker tells me it can't resolve symbols, but they're there?

点点圈 提交于 2019-11-28 04:02:42
问题 I am trying to compile a simple test app using a library I've written. This compiles and runs fine on other machines. I have libroller.so available at /usr/lib. I'm compiling a main.cpp as such: g++ -g3 -Wall -I"../../" -lrt -lroller -o rap main.o It complains of numerous errors such as: /....../main.cpp:51: undefined reference to `Log::i(char const*, ...)' However, I know that these exist in this so: nm -Ca /usr/lib/libroller.so | grep "Log::i" 00000000001f5d50 T Log::i(char const*, ...)

C error: undefined reference to function, but it IS defined

我的未来我决定 提交于 2019-11-28 03:33:01
Just a simple program, but I keep getting this compiler error. I'm using MinGW for the compiler. Here's the header file, point.h : //type for a Cartesian point typedef struct { double x; double y; } Point; Point create(double x, double y); Point midpoint(Point p, Point q); And here's point.c : //This is the implementation of the point type #include "point.h" int main() { return 0; } Point create(double x, double y) { Point p; p.x = x; p.y = y; return p; } Point midpoint(Point p, Point q) { Point mid; mid.x = (p.x + q.x) / 2; mid.y = (p.y + q.y) / 2; return mid; } And here's where the compiler

AVR linker error, “relocation truncated to fit”

断了今生、忘了曾经 提交于 2019-11-28 03:30:59
问题 I'm trying to compile some code for an ATmega328 micro, and I want use the libraries and the core of Arduino. I'm using CMake. I have gotten to compile the core library and all objects of my code and the libraries of Arduino. But when it's linking, they show me the following error. ..."relocation truncated to fit: R_AVR_13_PCREL against symbol"..."avr5/libgcc.a"... I have found through Google that this is a common error, but no solution has worked for me. The only thing I can't do is put "-lm

Undefined reference to t1sl_steup_key_block when linking OpenSSL

风格不统一 提交于 2019-11-28 02:02:01
I got a problem of linking an OpenSSL library into an existing project. Where I do get it wrong? Below are the steps I have followed. I have downloaded the SSL library, configured and installed it. It gets installed in /usr/local/ssl . 2) I have copied libcrypto.a and libssl.a from /usr/local/ssl/lib into my project, something like /mnt/linux/bla/bla/lib . 3) Then I edit the make file and added path of libssl libcrpto there. The path added is one that is in project like /mnt/linux/bla /bla 3) make 4) build project via slick edit When it builds I get a long error chain, like ../lib/libssl.a(t1

How to dllimport in Microsoft Visual C++

跟風遠走 提交于 2019-11-28 01:08:09
问题 I have a DLL and I would like to use some of its functions. #include <iostream> using namespace std; extern "C" __declspec(dllimport) int Initialize(char* localPort, char* adminServerName, int rpcTimeout); int main() { int res = Initialize("7864", "6000@kabc", 10000); return 0; } I don't have the DLL's .lib file, so is there anyway I can link to it. One thing that comes to my mind is to use the LoadLibrary function and then use the GetProcAddress(). Is there any other way? When I compile the

Visual Studio error: LNK1104: cannot open file 'kernel32.lib' - only in WP8 projects / Win32 builds

安稳与你 提交于 2019-11-28 00:47:42
问题 I ran into this problem recently (few days ago everything was working fine): Visual Studio 2012 started to refuse to build native WP8 projects. Today, I created new solution from template 'Windows Phone Direct3D App (Native Only)' to check if my newly created DLLs will be properly supported on WP. I tried to compile this project, first without any changes or additional references - pure code generated by VS. However, it failed with given error. I know very well what does it mean and what

How do I specify, which version of boost library to link to?

浪子不回头ぞ 提交于 2019-11-27 23:45:42
I'm trying to migrate a project written in VS2012 to VS2013. I successfully compiled boost 1.53.0 (I first tried 1.54.0, but got some compiler errors) and got libraries like libboost_filesystem-vc120-mt-1_53.lib . But when trying to build my project, the linker complains: error LNK1104: cannot open file 'libboost_filesystem-vc110-mt-1_53.lib' I've been looking for some project settings in my entire solution to find out, why it's trying to load the older library version, but I didn't find anything. How does the linker know, which library to use? And how can I fix my problem? Ben I found the

Calling C++ method from Objective C

╄→尐↘猪︶ㄣ 提交于 2019-11-27 18:37:12
I have the following files. foo.h (C++ header file) foo.mm (C++ file) test_viewcontroller.h (objective c header file) test_viewcontroller.m (Objective c file) I have declared a method donothing() in foo.h and defined it in foo.mm.Lets say it is double donothing(double a) { return a; } Now,I try to call this function in test_viewcontroller.m double var = donothing(somevar); I get linker error which says "cannot find symbols" _donothing() in test_viewcontroller.o collect2: ld returned 1 exit status Can anyone please point me as to what is wrong? Let me be precise : #ifdef __cplusplus extern "C"

Link error while building a unit test target

淺唱寂寞╮ 提交于 2019-11-27 17:35:52
I have a XCode4 / iOS project with a regular target and unit test target. Everything works fine, except when I try to #import one of my classes in my test class and try to use it. If I try to build the unit test target, I get the following link error: Undefined symbols for architecture i386: "_OBJC_CLASS_$_FRRCategory", referenced from: objc-class-ref in CategoryTests.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status In CategoryTests.m I'm importing the header file in this way: #import "../todoro/FRRCategory.h" What am I doing wrong? Joe Make sure that the