Category : linker

In C++11 I have a problematic line, when it’s commented my programs runs perfect. when I uncomment it it causes tons of errors. My line is: jobs.insert(std::lower_bound(jobs.begin(), jobs.end(), job), job); In the following function: void JobsList::addJob(Command *cmd, bool isStopped) { JobEntry tmp{}; tmp.pid = 0; //getLastJob(&tmp.jid); ++tmp.jid; tmp.stopped = isStopped; tmp.cmd = cmd->cmd; time(&tmp.in_time); for ..

Read more

I have a DLL I was handed down by a device manufacturer. I can effortlessly call all its functions from a MS Console application (not from Qt or C++ Builder) but not from an MFC/WinAPI application? In an effort to work around the problem, I’m exploring the LoadLibrary() route. I am experimenting with this code, ..

Read more

Note: this didn’t solve my problem as I can’t initialise a stack in C++ (as I know): Undefined reference to static variable c++ In C++ I wrote: class ChangeDirCommand : public BuiltInCommand { static std::stack<char*> dir; public: ChangeDirCommand(const char* cmd_line); virtual ~ChangeDirCommand() {} void execute() override; }; and had the following implementation: void ChangeDirCommand::execute() { ..

Read more

tl;dr Is there a certain way to link libraries to ensure that thread_local variables are properly defined? I have a class along the lines of engine.h class Engine { private: std::mt19937_64 m_engine; public: Engine() = default; ~Engine() {} std::mt19937_64& get() { return m_engine; } }; and another class that uses it, threadrandom.h #include "engine.h" class ..

Read more

No matter what I do I seem to be getting a "undefined reference to dladdr" linking error when compiling the following minimal program (on Ubuntu linux 18.04 with gcc 7.5.0) g++ -o test src/main.cpp -I/opt/netgen/include -L/opt/netgen/lib -lnglib -pthread -ldl #include<iostream> namespace nglib { #include <nglib.h> } int main() { nglib::Ng_Init(); nglib::Ng_Exit(); } I have tried ..

Read more

when cpp code Linking on vscode must define json file like below. { "version": "2.0.0", "tasks": [ { "type": "cppbuild", "label": "C/C++: g++ 활성 파일 빌드", "command": "/usr/bin/g++", "args": [ "-g", "glad.c", "-pthread", "-o", "main", "main.cpp", "-lglfw", "-lGLU", "-lGL", "-lXrandr", "-lXxf86vm", "-lXinerama", "-lX11", "-lrt", "-ldl", ], "options": { "cwd": "${workspaceFolder}" }, "problemMatcher": [ "$gcc" ], ..

Read more

I got the error undefined reference to `memset’ while linking, it compiled fine. I googled the error but nothing helped. The function has a declaration and I really have no idea what the problem is. I’m on manjaro linux using gcc linker command: ld -T kernel.ld -static -Bsymbolic -nostdlib -o bin/kernel.elf lib/kernel.o lib/MemoryManagement/Bitmap.o lib/MemoryManagement/efiMemory.o lib/MemoryManagement/MemHandler.o ..

Read more