undefined-reference

linking pthread library issue

半腔热情 提交于 2020-04-13 06:00:51
问题 Am facing a problem that may be slightly complicated to explain and understand as giving the entire picture would be too big and difficult. Please excuse me for it. Consider the following Makefile: all: clients.so simulator backup LD_PRELOAD=/home/Juggler/client/clients.so ./simulator backup: backup.c libclient.a gcc backup.c -o backup -L /home/Juggler/client -L. -lclient -ldl simulator: simulator.c libclient.a gcc -g simulator.c -o simulator -L /home/Juggler/client -L. -lclient -ldl -pthread

RapidXML print header has undefined methods

时光毁灭记忆、已成空白 提交于 2020-03-17 05:44:11
问题 I've been messing with using RapidXML on one of my projects. It was all going so well until I decided to use it for writing out xml. My code is more or less as follows: //attempt to open the file for writing std::ofstream file(fileName.c_str()); if (!file.is_open()) return false; //the file didn't open xml_document<> doc; //creates the contents of the document... //... //... //write the document out to the file file << doc; //if I remove this line it compiles...but I kinda need this line to

undefined reference to `sin', even though I use <math.h> and -lm [duplicate]

僤鯓⒐⒋嵵緔 提交于 2020-01-20 08:56:51
问题 This question already has answers here : Undefined reference to 'pow' even though -lm is a compile flag. [C] (2 answers) Closed 23 days ago . I noticed that when I use sin inside function the compiler don't recognize it, here is an example: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> float sinus(float a){ return sin(a);} int main(int argc, char **argv) { double a = sinus(2); printf("%f \n", sin(2)); printf("%f", a); return 0; } If I use it directly in main it

Undefined reference to mempcy@GLIBC_2.14 when compiling on Linux

六月ゝ 毕业季﹏ 提交于 2020-01-19 01:49:26
问题 I am trying to port an application to drive a device that uses an ftdi2332h chip from windows to linux. I installed the libftd2xx library on an ubuntu 10.04 system per these instructions. When I try to compile any of the sample programs I get the following error: /usr/local/lib/libftd2xx.so: undefined reference to `memcpy@GLIBC_2.14' collect2: ld returned 1 exit status Any guidelines on how to fix this? 回答1: The mempcy@GLIBC_2.14 is called a versioned symbol. Glibc uses them while other

Undefined reference to mempcy@GLIBC_2.14 when compiling on Linux

旧城冷巷雨未停 提交于 2020-01-19 01:49:05
问题 I am trying to port an application to drive a device that uses an ftdi2332h chip from windows to linux. I installed the libftd2xx library on an ubuntu 10.04 system per these instructions. When I try to compile any of the sample programs I get the following error: /usr/local/lib/libftd2xx.so: undefined reference to `memcpy@GLIBC_2.14' collect2: ld returned 1 exit status Any guidelines on how to fix this? 回答1: The mempcy@GLIBC_2.14 is called a versioned symbol. Glibc uses them while other

What is an undefined reference/unresolved external symbol error and how do I fix it?

佐手、 提交于 2020-01-16 19:47:05
问题 What are undefined reference/unresolved external symbol errors? What are common causes and how to fix/prevent them? Feel free to edit/add your own. 回答1: Compiling a C++ program takes place in several steps, as specified by 2.2 (credits to Keith Thompson for the reference): The precedence among the syntax rules of translation is specified by the following phases [see footnote] . Physical source file characters are mapped, in an implementation-defined manner, to the basic source character set

Undefined reference to my own library

余生长醉 提交于 2020-01-15 08:48:25
问题 I've created my lib.a file with several gcc -c file.c -o file.o then ar sr lib/libtest.a file1.o file2.o file3.o confirmed with ar -t lib/libtest.a file1.o file2.o file3.o but when I try to compile test aplication gcc lib/libtest.a test.c -o test I got undefined reference in function main : to used function from file1.o, file2.o, file3.o 回答1: Order matters with libraries - try: gcc test.c -o test lib/libtest.a Basically, the linker reads the library when it comes across it on the list of

Calling a C++ function from a C program

南楼画角 提交于 2020-01-14 04:42:08
问题 How can I call a C++ function from a C program, is it possible?, and if it is how can I do it?. Thank you. 回答1: If you are trying to call a C++ function from C, then you are probably running into name mangling issues. The compiler does this in order to support function overloading and other features of C++. You can use extern "C" to inform the C++ compiler that the function CMACInit() will be called from C code: extern "C" CMACInit() { ... } When declared in this way, the C++ compiler will

Undefined reference to

徘徊边缘 提交于 2020-01-11 12:32:29
问题 I keep getting this error message every time I try to compile, and I cannot find out what the problem is. any help would be greatly appreciated: C:\DOCUME~1\Patrick\LOCALS~1\Temp/ccL92mj9.o:main.cpp:(.txt+0x184): undefined reference to 'List::List()' C:\DOCUME~1\Patrick\LOCALS~1\Temp/ccL92mj9.o:main.cpp:(.txt+0x184): undefined reference to 'List::add(int)' collect2: ld returned 1 exit status code: //List.h #ifndef LIST_H #define LIST_H #include <exception> //brief Definition of linked list

Undefined reference to

无人久伴 提交于 2020-01-11 12:32:29
问题 I keep getting this error message every time I try to compile, and I cannot find out what the problem is. any help would be greatly appreciated: C:\DOCUME~1\Patrick\LOCALS~1\Temp/ccL92mj9.o:main.cpp:(.txt+0x184): undefined reference to 'List::List()' C:\DOCUME~1\Patrick\LOCALS~1\Temp/ccL92mj9.o:main.cpp:(.txt+0x184): undefined reference to 'List::add(int)' collect2: ld returned 1 exit status code: //List.h #ifndef LIST_H #define LIST_H #include <exception> //brief Definition of linked list