undefined-reference

Undefined symbols error when using a header file

北城余情 提交于 2019-11-27 02:24:30
问题 I'm getting the following error and can't for the life of me figure out what I'm doing wrong. $ gcc main.c -o main Undefined symbols: "_wtf", referenced from: _main in ccu2Qr2V.o ld: symbol(s) not found collect2: ld returned 1 exit status main.c: #include <stdio.h> #include "wtf.h" main(){ wtf(); } wtf.h: void wtf(); wtf.c: void wtf(){ printf("I never see the light of day."); } Now, if I include the entire function in the header file instead of just the signature, it complies fine so I know

undefined reference to `__gxx_personality_sj0`

自古美人都是妖i 提交于 2019-11-27 01:27:01
With gcc 4.6 when trying to execute this code: #include <iostream> using namespace std; #include <bitset> int main() { //Int<> a; long long min = std::numeric_limits<int>::min(); unsigned long long max = std::numeric_limits<int>::max(); cout << "min: " << min << '\n'; cout << "max: " << max << '\n'; cout << (min <= max); std::bitset<64> minimal(min); cout << "minimal: " << minimal; return 0; } I'm getting the following error: 1. undefined reference to __gxx_personality_sj 2. undefined reference to _Unwind_SjLj_Register 3. undefined reference to _Unwind_SjLj_Unregister 4. undefined reference to

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

ぐ巨炮叔叔 提交于 2019-11-27 00:05:41
问题 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) {

undefined reference to template function [duplicate]

二次信任 提交于 2019-11-27 00:02:07
This question already has an answer here: “Undefined reference to” template class constructor [duplicate] 3 answers I have three files . The contents of main.cpp are #include<iostream> #include<QString> #include "util.h" int main() { using Util::convert2QString; using namespace std; int n =22; QString tmp = convert2QString<int>(n); return 0; } util.h namespace Util { template<class T> QString convert2QString(T type , int digits=0); } util.cpp namespace Util { template<class T> QString convert2QString(T type, int digits=0) { using std::string; string temp = (boost::format("%1%") % type).str();

How to include data object files (images, etc.) in program and access the symbols?

纵饮孤独 提交于 2019-11-26 23:28:39
问题 I've turned a couple of resource files into .obj files using objcopy and i link them with my programs source code. I can very well access the symbols inside the object file in my program with the following code, but only with GCC/G++ (Cygwin): extern uint8_t data[] asm("_binary_Resources_0_png_start"); extern uint8_t size[] asm("_binary_Resources_0_png_size"); extern uint8_t end[] asm("_binary_Resources_0_png_end"); The code doesn't work in Visual Studio, probably because VS has it's own _

Undefined reference to `initscr' Ncurses

倖福魔咒の 提交于 2019-11-26 22:41:15
I'm trying to compile my project and I use the lib ncurse. And I've got some errors when compiler links files. Here is my flags line in Makefile: -W -Wall -Werror -Wextra -lncurses I've included ncurses.h Some layouts : prompt$> dpkg -S curses.h libslang2-dev:amd64: /usr/include/slcurses.h libncurses5-dev: /usr/include/ncurses.h libncurses5-dev: /usr/include/curses.h prompt$> dpkg -L libncurses5-dev | grep .so /usr/lib/x86_64-linux-gnu/libncurses.so /usr/lib/x86_64-linux-gnu/libcurses.so /usr/lib/x86_64-linux-gnu/libmenu.so /usr/lib/x86_64-linux-gnu/libform.so /usr/lib/x86_64-linux-gnu

C++ undefined reference to template class method [duplicate]

谁说我不能喝 提交于 2019-11-26 21:45:08
问题 This question already has answers here : Why do I get “unresolved external symbol” errors when using templates? [duplicate] (3 answers) Undefined reference to template members (1 answer) Closed 6 years ago . I always get undefined reference to `Graph::InsertVertex(std::string)' if I compile my project! Any hints why he cant resolve this reference? (all Files are in the netbeans project folder) // main.cpp #include <cstdlib> #include <string> #include "Graph.h" using namespace std; int main

Qt: Signals and slots Error: undefined reference to `vtable for

牧云@^-^@ 提交于 2019-11-26 18:28:48
问题 Following example from this link: http://developer.kde.org/documentation/books/kde-2.0-development/ch03lev1sec3.html #include <QObject> #include <QPushButton> #include <iostream> using namespace std; class MyWindow : public QWidget { Q_OBJECT // Enable slots and signals public: MyWindow(); private slots: void slotButton1(); void slotButton2(); void slotButtons(); private: QPushButton *button1; QPushButton *button2; }; MyWindow :: MyWindow() : QWidget() { // Create button1 and connect button1-

DSO missing from command line [duplicate]

夙愿已清 提交于 2019-11-26 17:49:05
This question already has an answer here: libpthread.so.0: error adding symbols: DSO missing from command line 11 answers Linking error: DSO missing from command line 3 answers I am trying to compile a C++ program like this: $ g++ -o Sniffer_Train main.cpp Sniffer_train.cpp Sniffer_train.h -lmysqlclient -lpcap However I get the following error: /usr/bin/ld: /tmp/cct6xeXD.o: undefined reference to symbol 'pthread_join@@GLIBC_2.4' //lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status I have no idea what this

gcc: undefined reference to

蓝咒 提交于 2019-11-26 17:28:36
问题 I would like to compile this. program.c #include <libavcodec/avcodec.h> int main(){ int i = avpicture_get_size(AV_PIX_FMT_RGB24,300,300); } Running this gcc -I$HOME/ffmpeg/include program.c gives error /tmp/ccxMLBme.o: In function `main': program.c:(.text+0x18): undefined reference to `avpicture_get_size' collect2: ld returned 1 exit status However, avpicture_get_size is defined. Why is this happening? 回答1: However, avpicture_get_size is defined. No, as the header ( <libavcodec/avcodec.h> )