linker-errors

C++ linker error when trying to build from object files made using makefile. Does not occur when I just build it

∥☆過路亽.° 提交于 2019-12-11 10:06:07
问题 I'm trying to make a makefile for a multi-file C++ project that builds object files, then builds my application from those object files. It works without any errors when I use the command: all: src/main.cpp src/main_funcs.cpp src/menu.cpp src/logging.cpp\ src/runonce.cpp src/wordify.cpp src/vte.cpp g++ -Wall `pkg-config --cflags gtk+-3.0, vte-2.91, glib-2.0, gio-2.0`\ -std=c++14 -o "updater" src/main.cpp src/main_funcs.cpp \ src/logging.cpp src/menu.cpp src/runonce.cpp \ src/wordify.cpp src

Unresolved external symbol error in exe but not in dll

强颜欢笑 提交于 2019-12-11 09:06:09
问题 I have a library (dll) which exposes a class along with its constructors which are supposed to be used in other modules (exe and dll). I am able to instantiate that class from other library modules but not exe modules. I get the linker error - 'error LNK2019: unresolved external symbol' during linking. I am confused why linking succeeds when used in other library projects and not exe project. Can somebody help me with this? the following is the class declaration: class __declspec(dllimport)

code guards fail

北慕城南 提交于 2019-12-11 08:59:19
问题 Take this files: a.h #ifndef A_H #define A_H char EL[] = "el"; #endif a.cpp #include "a.h" b.h #ifndef B_H #define B_H #include "a.h" #endif b.cpp #include "b.h" main.cpp #include "b.h" #include "a.h" int main() { } This is only an example, but I've really this problem: g++ -c a.cpp g++ -c b.cpp g++ -c main.cpp g++ -o main main.o a.o b.o a.o:(.data+0x0): multiple definition of `EL' main.o:(.data+0x0): first defined here b.o:(.data+0x0): multiple definition of `EL' main.o:(.data+0x0): first

Missing something in arm g++

半腔热情 提交于 2019-12-11 08:56:33
问题 I installed the CodeSourcery g++ toolchain and tried to compile a simple hello world program: #include <iostream> using namespace std; int main() { cout << "Hello World" << endl; return 0; } And got a lot of errors from the linker $ arm-none-eabi-g++ helloworld.cpp -o helloworld.exe bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000008018 lib/libc.a(lib_a-abort.o): In function `abort': abort.c:(.text.abort+0x10): undefined reference to `_exit' lib/libc.a(lib_a-fstatr.o

Linking SDL_image errors

心不动则不痛 提交于 2019-12-11 07:09:49
问题 I am trying to install UltraStarDeluxe on a linux machine. The make uses compile scripts generated by fpc (Free Pascal) . On invoking make , the following is the error+warning message before ld exits: /usr/bin/ld: warning: ../game/link.res contains output sections; did you forget -T? /usr/bin/ld: cannot find -lSDL_image /home/sriram/ultraDX/ultrastardx-1.1-src/src/ultrastardx.dpr(344,1) Error: Error while linking /home/sriram/ultraDX/ultrastardx-1.1-src/src/ultrastardx.dpr(344,1) Fatal: There

Getting dynamic atexit destructor link error with custom toolset - eh vector destructor

吃可爱长大的小学妹 提交于 2019-12-11 06:39:55
问题 I'm getting a weird linker error when trying to compile against a VS2005 CRT with a Visual Studio 2015 toolset. The same code compiles perfect on any other toolset version (2005,2010,2012,2013). The code must compile under VS2005 CRT to properly link with other projects. How to reproduce: Create a new empty Dynamic Library (dll) project (In VS2015, toolset v140), add a source (.cpp) file: //1.cpp #include <string> static std::wstring thisWillFail[] = { L"test" }; Change the VC++ include

Linking error while using htmlcxx with dev-cpp

旧巷老猫 提交于 2019-12-11 06:23:19
问题 I have small program using htmlcxx but when I try building the code it gives linker error. I just downloaded the htmlcxx.084.zip, unzipped it and placed it in Dev-Cpp\include\c++\3.4.2\htmlcxx. The code does not give any build error but the linking fails. [Linker error] undefined reference to `htmlcxx::HTML::ParserDom::parseTree(std::string const&)' [Linker error] undefined reference to `htmlcxx::HTML::operator<<(std::ostream&, tree<htmlcxx::HTML::Node, std::allocator<tree_node_<htmlcxx::HTML

g++ undefined reference to library symbols [duplicate]

半城伤御伤魂 提交于 2019-12-11 06:08:28
问题 This question already has answers here : Why does the order in which libraries are linked sometimes cause errors in GCC? (9 answers) Closed 2 years ago . There are linker errors to Symbols defined by SFML, but i cannot see how they occur despite that I linked the lib. I'm using make, which I currently learn and I want to build a minimalistic dev-environment with it. Give a holler if you need anymore information than the following. I'd just like to minimize the questions size. XXX@XXX ~

C++ private static member variables

馋奶兔 提交于 2019-12-11 05:29:42
问题 This C++ code is producing linker errors at compile time: // A.h class A { public: static void f(); private: static std::vector<int> v; }; // A.cpp void A::f() { // this line is causing trouble int i = v.size(); } Moving the vector declaration into the cpp file works. However I want to understand the linker error "Undefined symbols" cause in the above code. What is causing the linker error in the above code? 回答1: Static members have to be defined in a compilation unit: // A.cpp vector<int> A:

Linker errors when trying to link code in tests using UnitTest++

蹲街弑〆低调 提交于 2019-12-11 04:48:29
问题 So I'm using Unittest++ (version 1.4) I've tried making a couple of dummy tests (CHECK(true) and CHECK(false), and those work fine. However, as soon as I try to include some production code, the linker goes nuts over using any class or function from the headers that I've included for testing. My questions are: Can this be caused by anything in UnitTest++? How do I set up my code or the project in Code::Blocks to make this error go away? Details: I have used unit testing before with java and C