undefined-reference

Undefined references when trying to link Qt app with my static library

左心房为你撑大大i 提交于 2019-12-01 02:17:54
问题 I have a static library that I have built with MinGW, I am trying to link to that library from a Qt application. I keep getting linker errors caused by one of the object files in the library. This file actually declares a couple of Boost headers, one for use of shared_ptr and the other so I can make a class noncopyable. I believe using this boost functionality is what is causing the issue but I have no idea why. If I comment out the classes in the Qt app that use the class defined in the file

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

孤街醉人 提交于 2019-12-01 01:52:46
问题 This question already has answers here : undefined reference to template function [duplicate] (2 answers) Closed 2 years ago . I keep getting undefined reference when i call the two functions from my template class "add" and "greater" in my main function. So, i have: number.h #ifndef NUMBER_H #define NUMBER_H template <class T> class number { public: T x; T y; number (int a, int b){ x=a; y=b;} int add (T&); T greater (); }; #endif number.cpp #include "number.h" template <class T> int number<T

Undefined reference on very simple program

余生颓废 提交于 2019-11-30 21:37:36
Once I installed Ubuntu 11.10, strange error appears. I want to use GD with my C program, so I installed package "libgd2-xpm-dev". Everything was installed - files gd.h and libgd.a are in "/usr/include" and in "/usr/lib". So, I've tried to compile simple program with GD. #include <stdio.h> #include <gd.h> int main() { gdImagePtr im, im_clear; int black, white; FILE *out1; im = gdImageCreate(100, 100); im_clear = gdImageCreate(100, 100); white = gdImageColorAllocate(im, 255, 255, 255); black = gdImageColorAllocate(im, 0, 0, 0); return 0; } $ gcc -lgd gd.c /tmp/cc6LReuX.o: In function `main':

getting error in c program “undefined reference to gettid”

白昼怎懂夜的黑 提交于 2019-11-30 12:46:39
This is my thread sub routine... Here, I am creating 4 threads and passing structure as a argument to thread sub routine. I am trying to print thread id with getid() function, I am getting error saying "undefined reference to gettid()". I have added necessary header files... #include <pthread.h> #include <stdio.h> #include <sys/types.h> #define ARRAYSIZE 17 #define NUMTHREADS 4 struct ThreadData { int start, stop; int* array; }; void* squarer(void* td) { struct ThreadData* data=(struct ThreadData*) td; int start=data->start; int stop=data->stop; int* array=data->array; int i; pid_t tid1; tid1

OpenCV - undefined reference: SurfFeatureDetector and BruteForceMatcher

◇◆丶佛笑我妖孽 提交于 2019-11-30 06:26:34
I'm making a program in C++ that uses 2 images to detect SURF Features, compute the matches with a bruteforcematcher and draws it. Here's the code #include <cstdio> #include <string> #include <vector> #include "opencv/cv.h" #include "opencv/highgui.h" #include "opencv2/features2d/features2d.hpp" using namespace cv; using namespace std; int main(int argc, char **argv){ if (argc <3) { cout << "Usage: " << argv[0] << " imageLocation1 imageLocation2" << endl; return -1; } Mat source1 = imread(argv[1],CV_LOAD_IMAGE_GRAYSCALE); Mat source2 = imread(argv[2],CV_LOAD_IMAGE_GRAYSCALE); if(source1.empty(

g++ undefined reference although symbol is present in *.so file

北城以北 提交于 2019-11-30 05:41:53
I found a number of similar questions (e.g. this , that or this ), but none of them helped me solve my problem. I have a *.so file (from the core of gnss-sdr ) that, as indicated by: $nm libgnss_system_parameters_dyn.so | c++filt |grep Gps_Eph contains the symbol Gps_Ephemeris::Gps_Ephemeris() , which is supposed to be a constructor. I've written some minimal code: #include <iostream> #include <core/system_parameters/gps_ephemeris.h> int main(int argc,const char* argv[]) { Gps_Ephemeris ge; return 0; } which I compile with: g++ main.cpp -std=c++0x -I some_include_path -L some_lib_path -l gnss

How to resovle __gcov_init undefined reference issue when link

微笑、不失礼 提交于 2019-11-30 01:18:28
I now work on C code coverage study and encountered following issue, GCC version 4.4.6: Added compiler flag CFLAGS = --coverage and linker option LDFLAGS := --coverage or LOCAL_LDLIBS := --coverage and got the error: undefined reference to '__gcov_init'" and "undefined reference to '__gcov_merge_add' Added option LOCAL_LDFLAGS := --coverage , and got link error: libgcov.a(_gcov.o): in function __gcov_set_sampling_rate: undefined reference to '__gcov_sampling_rate' libgcov.a(_gcov.o): in function gcov_exit: undefined reference to '__gcov_pmu_profile_filename' libgcov.a(_gcov.o): in function _

Undefined reference to 'inflateInit2_'

大兔子大兔子 提交于 2019-11-29 10:27:22
I'm using Code Blocks IDE and I want to install Tiled Map Editor for SFML. So, I downloaded the source and imported it to my project. Unfortunately, the build finished with an error due to missing zlib library. I downloaded it and built again. This time I received an error that reads: undefined reference to `inflateInit2_'| undefined reference to `inflateEnd'| undefined reference to `inflateEnd'| On the Internet I found the advice to join the linker command -lz , but the compiler refuses throwing the error: cannot find -lz . Does anyone know how to fix it? Use the option -L<path> to tell the

gcc undefined reference to

我只是一个虾纸丫 提交于 2019-11-29 10:01:29
I'm running.. gcc -c -I/usr/vt/sample ttssample.c gcc -L. -lttsapi ttssample.o -o ttsample and I'm getting the following error... ttssample.o: In function `_TTSFile': ttssample.c:(.text+0x352): undefined reference to `TTSRequestFile' ttssample.o: In function `_TTSFileEx': ttssample.c:(.text+0x5e0): undefined reference to `TTSRequestFileEx' ttssample.o: In function `_TTSBuffer': ttssample.c:(.text+0x833): undefined reference to `_TTSRequestBuffer' ttssample.o: In function `_TTSBufferEx': ttssample.c:(.text+0xabd): undefined reference to `_TTSRequestBufferEx' ttssample.o: In function `

Using GCC Undefined Behavior Sanitizer

大兔子大兔子 提交于 2019-11-29 09:17:15
Today I have read an article about GCC Undefined Behavior Sanitizer (ubsan) . However, when I follow steps there (add -fsanitize=undefined to my code), the compiler (GCC 4.9.2 on Ubuntu 15.04) says that some references are not defined: ||=== Build: Debug in Entangle (compiler: GNU GCC Compiler) ===| obj/Debug/EntangleApp.o||In function `EntangleApp::OnInit()':| /home/ilya/Projects/Entangle/EntangleApp.cpp|31|undefined reference to `__ubsan_handle_type_mismatch'| /home/ilya/Projects/Entangle/EntangleApp.cpp|31|undefined reference to `__ubsan_handle_load_invalid_value'| /home/ilya/Projects