I am compiling my code using PGI compiler with openmpi with -multicore flag and I get this error.
undefined reference to `**__pgi_uacc_cuda_stream**'
undefined reference to `**__pgi_uacc_cuda_initdinfoflags**'
undefined reference to `**__pgi_uacc_cuda_release_buffer**'
undefined reference to **'__pgi_uacc_cuda_argmem'**
I have removed all the async flags from my code
//#pragma acc update device( ptr[0 : end] ) async( 3 )
Related
Downloaded lua5_1_4_Sources.tar.gz and compiled liblua.a from source using TDM-GCC 4.5.1.
Everything compiled fine:
Linking ..
ar rcs liblua.a 5.1.4/src/lapi.o 5.1.4/src/lauxlib.o 5.1.4/src/lbaselib.o 5.1.4/src/lcode.o 5.1.4/src/ldblib.o 5.1.4/s rc/ldebug.o 5.1.4/src/ldo.o 5.1.4/src/ldump.o 5.1.4/src/lfunc.o 5.1.4/src/lgc.o 5.1.4/src/linit.o 5.1.4/src/liolib.o 5.1 .4/src/llex.o 5.1.4/src/lmathlib.o 5.1.4/src/lmem.o 5.1.4/src/loadlib.o 5.1.4/src/lobject.o 5.1.4/src/lopcodes.o 5.1.4/s rc/loslib.o 5.1.4/src/lparser.o 5.1.4/src/lstate.o 5.1.4/src/lstring.o 5.1.4/src/lstrlib.o 5.1.4/src/ltable.o 5.1.4/src/ ltablib.o 5.1.4/src/ltm.o 5.1.4/src/lua.o 5.1.4/src/luac.o 5.1.4/src/lundump.o 5.1.4/src/lvm.o 5.1.4/src/lzio.o 5.1.4/sr c/print.o 5.1.4/src/wmain.o
Compiled example source just fine:
http://pastebin.com/EGvMRjth
Tried to link:
Compiling..
g++ test.o -g -shared -Lshared/build/lua -llua -o libtest.so
test.o:test.cpp:(.text+0x15): undefined reference to `lua_tonumber(lua_State*, int)'
test.o:test.cpp:(.text+0x40): undefined reference to `lua_pushnumber(lua_State*, double)'
test.o:test.cpp:(.text+0x60): undefined reference to `lua_tonumber(lua_State*, int)'
test.o:test.cpp:(.text+0x8e): undefined reference to `lua_pushnumber(lua_State*, double)'
test.o:test.cpp:(.text+0xb6): undefined reference to `lua_pushcclosure(lua_State*, int (*)(lua_State*), int)'
test.o:test.cpp:(.text+0xd1): undefined reference to `lua_setfield(lua_State*, int, char const*)'
test.o:test.cpp:(.text+0xec): undefined reference to `lua_pushcclosure(lua_State*, int (*)(lua_State*), int)'
test.o:test.cpp:(.text+0x107): undefined reference to `lua_setfield(lua_State*, int, char const*)'
collect2: ld returned 1 exit status
I'm trying to follow the examples from here:
http://www.troubleshooters.com/codecorn/lua/lua_lua_calls_c.htm
As already discussed in the comments..
It seems you are compiling C++ and the Lua version you use is probably coded in C.
This means you need to include either the lua.hpp or if not available you need to include the libraries by using extern "C" like so:
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
};
Well, it's a very strange error I met.
When I try to compile my program with the fftw library by the command:
g++ -std=c++11 -o main main.cpp BFSCcommandlineParser.cpp BFSCframe.cpp BFSCgeometry.cpp ImageIO.cpp -lfftw3 -lm
... I get this:
/tmp/cczUuTb0.o: In function `fftw_prog::fftw_prog(char const*)':
main.cpp:(.text._ZN9fftw_progC2EPKc[_ZN9fftw_progC5EPKc]+0x5c): undefined reference to `fftwf_import_wisdom_from_file'
/tmp/cczUuTb0.o: In function `fftw_prog::~fftw_prog()':
main.cpp:(.text._ZN9fftw_progD2Ev[_ZN9fftw_progD5Ev]+0x31): undefined reference to `fftwf_export_wisdom_to_file'
/tmp/cczUuTb0.o: In function `fft<2, float, std::complex<float> >::fft(tensor<int, 2ul>, bool)':
main.cpp:(.text._ZN3fftILi2EfSt7complexIfEEC2E6tensorIiLm2EEb[_ZN3fftILi2EfSt7complexIfEEC5E6tensorIiLm2EEb]+0xcf): undefined reference to `fftwf_plan_dft_r2c'
main.cpp:(.text._ZN3fftILi2EfSt7complexIfEEC2E6tensorIiLm2EEb[_ZN3fftILi2EfSt7complexIfEEC5E6tensorIiLm2EEb]+0x111): undefined reference to `fftwf_plan_dft_c2r'
/tmp/cczUuTb0.o: In function `fft<2, float, std::complex<float> >::~fft()':
main.cpp:(.text._ZN3fftILi2EfSt7complexIfEED2Ev[_ZN3fftILi2EfSt7complexIfEED5Ev]+0x25): undefined reference to `fftwf_free'
main.cpp:(.text._ZN3fftILi2EfSt7complexIfEED2Ev[_ZN3fftILi2EfSt7complexIfEED5Ev]+0x35): undefined reference to `fftwf_destroy_plan'
main.cpp:(.text._ZN3fftILi2EfSt7complexIfEED2Ev[_ZN3fftILi2EfSt7complexIfEED5Ev]+0x45): undefined reference to `fftwf_destroy_plan'
/tmp/cczUuTb0.o: In function `fft<2, float, std::complex<float> >::r2F()':
main.cpp:(.text._ZN3fftILi2EfSt7complexIfEE3r2FEv[_ZN3fftILi2EfSt7complexIfEE3r2FEv]+0x25): undefined reference to `fftwf_execute'
/tmp/cczUuTb0.o: In function `fft<2, float, std::complex<float> >::F2r()':
main.cpp:(.text._ZN3fftILi2EfSt7complexIfEE3F2rEv[_ZN3fftILi2EfSt7complexIfEE3F2rEv]+0x35): undefined reference to `fftwf_execute'
collect2: error: ld returned 1 exit status
I thought it could be a problem of fftw itself, so I tested the library with a proram, and it worked. That means that it's not so.
The following code is a template from my file which is the only one in my project that uses fftw.
template <int N, typename rT, typename FT>
inline fft<N,rT,FT>::~fft() {
if (data != 0) {
if (Precision<rT>::IsFloat) {
fftwf_free((fftwf_complex *)data);
fftwf_destroy_plan((fftwf_plan_s*) r2Fplan);
fftwf_destroy_plan((fftwf_plan_s*) F2rplan);
}
else {
fftw_free((fftw_complex *)data);
fftw_destroy_plan((fftw_plan_s*) r2Fplan);
fftw_destroy_plan((fftw_plan_s*) F2rplan);
}
}
}
For single precision (float) you need to link the libfftwf library, for double precision (double) you need the libfftw library. I would guess you are just linking the latter and not the former. For gcc et al the command line needs to contain -lfftw3 -lfftw3f if you want both double and single precision support.
I'm attempting to follow the steps on http://llvm.org/docs/tutorial/LangImpl3.html to build the example.
based on
Building llvm examples
#error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
Why am I getting "undefined reference to `dladdr'" even with -ldl for this simple program?
I've ended up with the command
clang++ -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -std=c++11 -g -O3 toy.cpp `llvm-config --libs core --cppflags --ldflags` -o toy
which is giving
/usr/local/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::MutexImpl(bool)':
/home/abdev/llvmHome/llvm/lib/Support/Mutex.cpp:53: undefined reference to `pthread_mutexattr_init'
/home/abdev/llvmHome/llvm/lib/Support/Mutex.cpp:59: undefined reference to `pthread_mutexattr_settype'
/home/abdev/llvmHome/llvm/lib/Support/Mutex.cpp:67: undefined reference to `pthread_mutexattr_destroy'
/usr/local/lib/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::tryacquire()':
/home/abdev/llvmHome/llvm/lib/Support/Mutex.cpp:109: undefined reference to `pthread_mutex_trylock'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::RWMutexImpl()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:59: undefined reference to `pthread_rwlock_init'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::~RWMutexImpl()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:72: undefined reference to `pthread_rwlock_destroy'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::reader_acquire()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:82: undefined reference to `pthread_rwlock_rdlock'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::reader_release()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:92: undefined reference to `pthread_rwlock_unlock'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::writer_acquire()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:102: undefined reference to `pthread_rwlock_wrlock'
/usr/local/lib/libLLVMSupport.a(RWMutex.o): In function `llvm::sys::RWMutexImpl::writer_release()':
/home/abdev/llvmHome/llvm/lib/Support/RWMutex.cpp:112: undefined reference to `pthread_rwlock_unlock'
/usr/local/lib/libLLVMSupport.a(Signals.o): In function `llvm::sys::PrintStackTrace(_IO_FILE*)':
/home/abdev/llvmHome/llvm/lib/Support/Unix/Signals.inc:278: undefined reference to `dladdr'
/home/abdev/llvmHome/llvm/lib/Support/Unix/Signals.inc:290: undefined reference to `dladdr'
/usr/local/lib/libLLVMSupport.a(ThreadLocal.o): In function `llvm::sys::ThreadLocalImpl::ThreadLocalImpl()':
/home/abdev/llvmHome/llvm/lib/Support/ThreadLocal.cpp:56: undefined reference to `pthread_key_create'
/usr/local/lib/libLLVMSupport.a(ThreadLocal.o): In function `llvm::sys::ThreadLocalImpl::~ThreadLocalImpl()':
/home/abdev/llvmHome/llvm/lib/Support/ThreadLocal.cpp:63: undefined reference to `pthread_key_delete'
/usr/local/lib/libLLVMSupport.a(ThreadLocal.o): In function `llvm::sys::ThreadLocalImpl::setInstance(void const*)':
/home/abdev/llvmHome/llvm/lib/Support/ThreadLocal.cpp:70: undefined reference to `pthread_setspecific'
/usr/local/lib/libLLVMSupport.a(ThreadLocal.o): In function `llvm::sys::ThreadLocalImpl::getInstance()':
/home/abdev/llvmHome/llvm/lib/Support/ThreadLocal.cpp:77: undefined reference to `pthread_getspecific'
/usr/local/lib/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)':
/home/abdev/llvmHome/llvm/lib/Support/Threading.cpp:91: undefined reference to `pthread_attr_setstacksize'
/home/abdev/llvmHome/llvm/lib/Support/Threading.cpp:96: undefined reference to `pthread_create'
/home/abdev/llvmHome/llvm/lib/Support/Threading.cpp:100: undefined reference to `pthread_join'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Am I missing a library, or is some of the order incorrect?
I believe you need to link with -lpthread or just -pthread
I'm using GCC (CygWin) cross-compiling targeting an Arm7 processor. the problem is none of the standard library functions are available for my program. as I understand it, libc.a is the library i should be using. strangely, this file has been copied to the application source directory.
I would've thought if I did the following, I should be able to use these functions:
have included (enclosed in <>) string.h and stdlib.h in my LCD.c file
mention libc.a to the linker
During make, here's what it says:
$ make
.compiling
..linking
arm-elf-ld -v -Map main.map -nostartfiles -T simple.cmd -o main.out start.o ivt.
o main.o libc.a LCD.o
GNU ld version 2.14 20030612
LCD.o(.text+0x75c): In function `LCD_DispSmallDigits':
: undefined reference to `strlen'
LCD.o(.text+0x22d4): In function `LCD_DispSelMsgAt':
: undefined reference to `malloc'
LCD.o(.text+0x22e0): In function `LCD_DispSelMsgAt':
: undefined reference to `strcpy'
LCD.o(.text+0x2308): In function `LCD_DispSelMsgAt':
: undefined reference to `free'
LCD.o(.text+0x2358): In function `LCD_DispNumMsgAt':
: undefined reference to `malloc'
LCD.o(.text+0x2368): In function `LCD_DispNumMsgAt':
: undefined reference to `sprintf'
LCD.o(.text+0x2384): In function `LCD_DispNumMsgAt':
: undefined reference to `free'
the code I'm using is quite mundane:
void LCD_DispSelMsgAt(int iRow, int iCol, int bSelected, char* s)
{
int i;
char* sBuffer = (char*) malloc(100);
strcpy(sBuffer, s);
if (bSelected)
for (i=0; i<strlen(sBuffer); i++)
if ((*(sBuffer + i)>='a') && (*(sBuffer + i)<='z'))
*(sBuffer + i) = (*(sBuffer + i)) - 0x20;
LCD_DispMsgAt(iRow, iCol, sBuffer);
free(sBuffer);
}
how can I get access to those standard routines?
thank you!
PS: it seems to me I'm having quite a "general" problem so what I'm about to say is not central to this question but i'll mention it anyway...
I noticed something that specifically relates to strlen( ). the prototype for strlen( ) has the parameter as "const char* s". it seems then it works fine with:
i = strlen("abc")
but not in the code sample routine shown above. that wouldn't be a very helpful library routine that can't be used as strlen(char* s).
reply to #n.m.:
adding /gnude/arm-elf/lib/libc.a to the linker command line introduced a "thousand" errors.
$ make
..linking
arm-elf-ld -v -Map main.map -nostartfiles -T LinkerScript.cmd -L /gnude/arm-elf/
lib -o main.out start.o ivt.o main.o LCD.o /gnude/arm-elf/lib/libc.a
GNU ld version 2.14 20030612
/gnude/arm-elf/lib/libc.a(syscalls.o)(.text+0x714): In function `_sbrk':
: undefined reference to `end'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x8c0): In function `_vfprintf_r':
: undefined reference to `__eqdf2'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1054): In function `_vfprintf_r':
: undefined reference to `__nedf2'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x155c): In function `_vfprintf_r':
: undefined reference to `__umoddi3'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1578): In function `_vfprintf_r':
: undefined reference to `__udivdi3'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1834): In function `_vfprintf_r':
: undefined reference to `__ltdf2'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1d98): In function `cvt':
: undefined reference to `__eqdf2'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1e10): In function `cvt':
: undefined reference to `__nedf2'
/gnude/arm-elf/lib/libc.a(vfprintf.o)(.text+0x1e30): In function `cvt':
: undefined reference to `__negdf2'
/gnude/arm-elf/lib/libc.a(dtoa.o)(.text+0x7c): In function `_dtoa_r':
: undefined reference to `__eqdf2'
not sure what i should do next. i think i'll start by removing the explicit libc.a from the linker command line.
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':
gd2.c:(.text+0x19): undefined reference to `gdImageCreate'
gd2.c:(.text+0x31): undefined reference to `gdImageCreate'
gd2.c:(.text+0x59): undefined reference to `gdImageColorAllocate'
gd2.c:(.text+0x81): undefined reference to `gdImageColorAllocate'
Wait, what? Okay, let's check something.
# Let's sure the lib was found.
$ gcc -lgd_something gd.c
/usr/bin/ld: cannot find -lgd_something
# Lets sure we made no mistake with the symbol's name
$ nm /usr/lib/libgd.a
...
00000dc0 T gdImageColorAllocate
...
000003b0 T gdImageCreate
# So, everything should be ok
$ gcc -lgd gd.c
/tmp/cc6LReuX.o: In function `main':
gd2.c:(.text+0x19): undefined reference to `gdImageCreate'
gd2.c:(.text+0x31): undefined reference to `gdImageCreate'
gd2.c:(.text+0x59): undefined reference to `gdImageColorAllocate'
gd2.c:(.text+0x81): undefined reference to `gdImageColorAllocate'
$ echo $LD_LIBRARY_PATH
# Nothing
And I don't know what shall I do. Is it an error in gcc or I do something wrong. On my previous os (Ubuntu 10.04) everything works well.
Which file should I show for you?
Change:
$ gcc -lgd gd.c
to:
$ gcc gd.c -lgd
(Reason: link order matters !)
Oh, and add -Wall while you're at it - it pains me greatly every time I see people compiling with warnings disabled.
$ gcc -Wall gd.c -lgd