I have build some code using LibSerial but when i compile it i have this error messages:
/tmp/ccUpE4te.o: In function `main':
test.c:(.text+0x8d): undefined reference to `LibSerial::SerialStream::Open(std::string, std::_Ios_Openmode)'
test.c:(.text+0xbf): undefined reference to `LibSerial::SerialStream::SetBaudRate(LibSerial::SerialStreamBuf::BaudRateEnum)'
test.c:(.text+0xd3): undefined reference to `LibSerial::SerialStream::SetCharSize(LibSerial::SerialStreamBuf::CharSizeEnum)'
test.c:(.text+0xe7): undefined reference to `LibSerial::SerialStream::SetNumOfStopBits(short)'
test.c:(.text+0xfb): undefined reference to `LibSerial::SerialStream::SetFlowControl(LibSerial::SerialStreamBuf::FlowControlEnum)'
test.c:(.text+0x10f): undefined reference to `LibSerial::SerialStream::SetVTime(short)'
test.c:(.text+0x123): undefined reference to `LibSerial::SerialStream::SetVMin(short)'
test.c:(.text+0x1a1): undefined reference to `LibSerial::SerialStream::Open(std::string, std::_Ios_Openmode)'
test.c:(.text+0x1d3): undefined reference to `LibSerial::SerialStream::SetBaudRate(LibSerial::SerialStreamBuf::BaudRateEnum)'
test.c:(.text+0x1e7): undefined reference to `LibSerial::SerialStream::SetCharSize(LibSerial::SerialStreamBuf::CharSizeEnum)'
test.c:(.text+0x1fb): undefined reference to `LibSerial::SerialStream::SetNumOfStopBits(short)'
test.c:(.text+0x20f): undefined reference to `LibSerial::SerialStream::SetFlowControl(LibSerial::SerialStreamBuf::FlowControlEnum)'
test.c:(.text+0x223): undefined reference to `LibSerial::SerialStream::SetVTime(short)'
test.c:(.text+0x237): undefined reference to `LibSerial::SerialStream::SetVMin(short)'
/tmp/ccUpE4te.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x48): undefined reference to `LibSerial::SerialStreamBuf::showmanyc()'
/tmp/ccUpE4te.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x50): undefined reference to `LibSerial::SerialStreamBuf::xsgetn(char*, long)'
/tmp/ccUpE4te.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x58): undefined reference to `LibSerial::SerialStreamBuf::underflow()'
/tmp/ccUpE4te.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x68): undefined reference to `LibSerial::SerialStreamBuf::pbackfail(int)'
/tmp/ccUpE4te.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x70): undefined reference to `LibSerial::SerialStreamBuf::xsputn(char const*, long)'
/tmp/ccUpE4te.o:(.rodata._ZTVN9LibSerial15SerialStreamBufE[_ZTVN9LibSerial15SerialStreamBufE]+0x78): undefined reference to `LibSerial::SerialStreamBuf::overflow(int)'
collect2: error: ld returned 1 exit status
I believe that they are linking errors but i cannot understand how i can solve my problem.
Solution: "gcc -L/usr/local/lib -lserial test.c"
What this solution means?
gcc doesn't know about the libraries you wish to use. You should tell him.
The gcc flag "-l" is the way telling gcc that you want to link to a library installed on you computer.
In your case you should specify: "-lserial"
Another thing you will need to do is to let g++ know where to find this library.
Assuming you didn't make anything special the libaray will be found under /usr/local/lib and will be named libserial.so
You can tell gcc where you keep your libraries by adding another flag "-L" (it should be -L/usr/local/lib) or you can use the local variable to do so:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Related
I know this is an old post, but I am trying to do what you did here but I am getting the below error. May you please help, I am new to VLC-Qt thing.
Thank you.
C:/Qt/5.15.0/mingw81_32/include/QtCore/qmetatype.h:1590: undefined reference to `VlcQmlPlayer::staticMetaObject'
debug/main.o: In function `ZN18QMetaTypeIdQObjectIP12VlcQmlPlayerLi8EE14qt_metatype_idEv':
C:/Qt/5.15.0/mingw81_32/include/QtCore/qmetatype.h:1951: undefined reference to `VlcQmlPlayer::staticMetaObject'
debug/main.o:main.cpp:(.rdata$_ZTVN11QQmlPrivate11QQmlElementI12VlcQmlPlayerEE[__ZTVN11QQmlPrivate11QQmlElementI12VlcQmlPlayerEE]+0x8): undefined reference to `VlcQmlPlayer::metaObject() const'
debug/main.o:main.cpp:(.rdata$_ZTVN11QQmlPrivate11QQmlElementI12VlcQmlPlayerEE[__ZTVN11QQmlPrivate11QQmlElementI12VlcQmlPlayerEE]+0xc): undefined reference to `VlcQmlPlayer::qt_metacast(char const*)'
debug/main.o:main.cpp:(.rdata$_ZTVN11QQmlPrivate11QQmlElementI12VlcQmlPlayerEE[__ZTVN11QQmlPrivate11QQmlElementI12VlcQmlPlayerEE]+0x10): undefined reference to `VlcQmlPlayer::qt_metacall(QMetaObject::Call, int, void**)'
debug/main.o: In function `ZN11QQmlPrivate11QQmlElementI12VlcQmlPlayerED1Ev':
C:/Qt/5.15.0/mingw81_32/include/QtQml/qqmlprivate.h:144: undefined reference to `VlcQmlPlayer::~VlcQmlPlayer()'
I'm having an issue linking my shared library against an OpenDDS (v3.9) static library because I am unable to find where this method signature is located.
Here's the error.
[exec] libs/mylib/ABTypeSupportImpl.cpp:74: error: undefined reference to 'OpenDDS::DCPS::operator<<(OpenDDS::DCPS::Serializer&, short)'
[exec] collect2: error: ld returned 1 exit status
[exec] make: *** [/tmp/mybuild/lib_ab/obj/local/armeabi-v7a/lib_ab.so] Error 1
ABTypeSupportImpl.cpp is auto generated from compiling the IDL. More of the same errors follow. Because of the namespace (OpenDDS::DCPS), I would think this would be found within the library libOpenDDS_Dcps.a, but using nm on this lib and then grep'ing for "operator" or "<<", produces no results. Could it be that name mangling is a bit stranger for overloaded operators? I ran this on every library file within $DDS_ROOT/lib, but found nothing.
And if I recompile the IDL and remove member fields of structs with datatypes such as short or long, then there are no errors and everything links fine.
Anyone know what library this method signature might be located?
These operators are declared in 'dds/DCPS/Serializer.h' but implemented inline in Serializer.inl. Probably you compile OpenDDS with inlining enabled (its default) but when you compile your application you compile with inlining disabled.
Summary:
I have a code snippet that compiles fine with g++ but not with clang.
Details:
I have a project that compiles fine with g++ but when compiling with clang I get an error about error: use of non-static data member. I tried to create a small test case that would demonstrate the problem, but for the small test case g++ gave the same error as clang.
I've posted a 236 line file to pastebin that demonstrates the problem:
http://pastebin.com/DGnfxmYe
When compiled with g++ 4.6.3 this works fine. But when compiled with clang 3.2 I get the following error messages:
myhashmap.hpp:169:29: error: use of non-static data member 'num_bins' of 'MyHashMap' from nested type 'iterator'
for (_index++; (_index < num_bins) && (bins[_index] == NULL); _index++)
^~~~~~~~
myhashmap.hpp:169:43: error: use of non-static data member 'bins' of 'MyHashMap' from nested type 'iterator'
for (_index++; (_index < num_bins) && (bins[_index] == NULL); _index++)
^~~~
myhashmap.hpp:171:17: error: use of non-static data member 'num_bins' of 'MyHashMap' from nested type 'iterator'
if (_index < num_bins) {
^~~~~~~~
myhashmap.hpp:172:17: error: use of non-static data member 'bins' of 'MyHashMap' from nested type 'iterator'
_theNode = bins[_index];
^~~~
Looking at the code, it makes sense to me why clang is giving these error messages. What I don't understand is why g++ compiled the code correctly in the first place. I did not write this code but I would like to get it to compile cleanly with clang. So I'm trying to understand exactly what it is doing. And I would be interested in understanding why it compiles with g++ but not with clang. Does g++ interpret the c++ standard differently, or is there some g++ extension that the code is taking advantage of?
It fails with GCC 4.8 (prerelease) so I assume it's a bug that's been fixed. I can't find a corresponding bug report though.
To fix the code I think you'll need add an int _num_bins member to the iterator and pass the cotnainer's num_bins to the iterator constructor in begin() and end(), so it's stored in each iterator object.
(Additionally, don't write (void) for a function taking no arguments, that's an abomination. In C++ a function taking no arguments is written ())
I am trying to create a custom TCL interpreter with TclPro according instructions at TclPro User's Guide Chapter 7, but it fails with linking error undefined reference to __ctype_b.
I have downloaded and installed TclPro 1.4 at /opt/ajuba/TclPro1.4/, and here is the custom interpreter I want to build:
// file simple.cpp
#include <proWrap.h>
int main( int argc, char** argv )
{
Pro_WrapTclMain( argc, argv, &Tcl_Init );
return 0;
}
So it does nothing but calls Pro_WrapTclMain with standard Tcl_Init.
I am trying to build simple.cpp with this command:
g++ -DNDEBUG -O3 -fpic -Wall -pedantic -I/opt/ajuba/TclPro1.4/include simple.cpp -static -Wl,-R/opt/ajuba/TclPro1.4/linux-ix86/lib -L/opt/ajuba/TclPro1.4/linux-ix86/lib -lwrapper1.4 -ltcl8.3 -o out
and here is the first error message I get (you can find the full log at the bottom):
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o): In function `envargs':
envargs.c:(.text+0x1e): undefined reference to `__ctype_b'
Seems __ctype_b is a symbol which TclPro expects to be defined at libc.a, but
nm /usr/lib/libc.a | grep __ctype_b
gives
00000080 T __ctype_b_loc
so there is no __ctype_b defined at libc.a.
The question is: how to build a custom TCL interpreter with TclPro in this situation?
If __ctype_b should be defined at libc.a, then how can I obtain an appropriate libc.a?
Here is the full log of compilation:
g++ -DNDEBUG -O3 -fpic -Wall -pedantic -I/opt/ajuba/TclPro1.4/include simple.cpp -static -Wl,-R/opt/ajuba/TclPro1.4/linux-ix86/lib -L/opt/ajuba/TclPro1.4/linux-ix86/lib -lwrapper1.4 -ltcl8.3 -o out
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixPipe.o): In function `TclpCreateTempFile':
tclUnixPipe.c:(.text+0xe0): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `GetGroupAttribute':
tclUnixFCmd.c:(.text+0xb5b): warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `SetGroupAttribute':
tclUnixFCmd.c:(.text+0xd59): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `GetGroupAttribute':
tclUnixFCmd.c:(.text+0xba1): warning: Using 'endgrent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `SetOwnerAttribute':
tclUnixFCmd.c:(.text+0xe7d): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixFCmd.o): In function `GetOwnerAttribute':
tclUnixFCmd.c:(.text+0xc14): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
tclUnixFCmd.c:(.text+0xc5e): warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixChan.o): In function `TcpGetOptionProc':
tclUnixChan.c:(.text+0x8de): warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclUnixChan.o): In function `CreateSocketAddress':
tclUnixChan.c:(.text+0xe4c): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclIOSock.o): In function `TclSockGetPort':
tclIOSock.c:(.text+0x47): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o): In function `envargs':
envargs.c:(.text+0x1e): undefined reference to `__ctype_b'
envargs.c:(.text+0x5d): undefined reference to `__ctype_b'
envargs.c:(.text+0x193): undefined reference to `__ctype_b'
envargs.c:(.text+0x1c0): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o): In function `count_args':
envargs.c:(.text+0x23d): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(envargs.o):envargs.c:(.text+0x29b): more undefined references to `__ctype_b' follow
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(fileio.o): In function `UzpMorePause':
fileio.c:(.text+0x9a8): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(fileio.o): In function `do_string':
fileio.c:(.text+0xf31): undefined reference to `__ctype_b'
fileio.c:(.text+0xf4a): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(fileio.o): In function `zstrnicmp':
fileio.c:(.text+0x120c): undefined reference to `__ctype_b'
fileio.c:(.text+0x1215): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(match.o): In function `recmatch':
match.c:(.text+0x127): undefined reference to `__ctype_tolower'
match.c:(.text+0x15f): undefined reference to `__ctype_b'
match.c:(.text+0x1ad): undefined reference to `__ctype_b'
match.c:(.text+0x24b): undefined reference to `__ctype_b'
match.c:(.text+0x264): undefined reference to `__ctype_tolower'
match.c:(.text+0x28d): undefined reference to `__ctype_b'
match.c:(.text+0x2a6): undefined reference to `__ctype_tolower'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libwrapper1.4.a(unix.o): In function `mapname':
unix.c:(.text+0x441): undefined reference to `__ctype_b'
unix.c:(.text+0x47b): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclIOUtil.o): In function `TclGetOpenMode':
tclIOUtil.c:(.text+0x36): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclListObj.o): In function `SetListFromAny':
tclListObj.c:(.text+0x7e6): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclLoad.o): In function `Tcl_LoadObjCmd':
tclLoad.c:(.text+0x3cc): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclObj.o):tclObj.c:(.text+0x7e8): more undefined references to `__ctype_b' follow
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclLoadDl.o): In function `TclpLoadFile':
tclLoadDl.c:(.text+0x35): undefined reference to `dlopen'
tclLoadDl.c:(.text+0x5a): undefined reference to `dlerror'
tclLoadDl.c:(.text+0xa1): undefined reference to `dlsym'
tclLoadDl.c:(.text+0xe0): undefined reference to `dlsym'
tclLoadDl.c:(.text+0x119): undefined reference to `dlsym'
tclLoadDl.c:(.text+0x158): undefined reference to `dlsym'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclLoadDl.o): In function `TclpUnloadFile':
tclLoadDl.c:(.text+0x19c): undefined reference to `dlclose'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclBinary.o): In function `Tcl_BinaryObjCmd':
tclBinary.c:(.text+0xbe4): undefined reference to `__ctype_b'
tclBinary.c:(.text+0xc5d): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclBinary.o): In function `GetFormatSpec':
tclBinary.c:(.text+0x1617): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclCmdAH.o): In function `Tcl_CaseObjCmd':
tclCmdAH.c:(.text+0x185): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclCmdAH.o): In function `Tcl_FormatObjCmd':
tclCmdAH.c:(.text+0x22f5): undefined reference to `__ctype_b'
/opt/ajuba/TclPro1.4/linux-ix86/lib/libtcl8.3.a(tclCmdAH.o):tclCmdAH.c:(.text+0x23f8): more undefined references to `__ctype_b' follow
collect2: ld returned 1 exit status
make: *** [out] Error 1
I don't know for sure what the details of your platform are, but this message would seem to hold the answer. In essence, you add this code to simple.cpp and recompile:
#include <ctype.h>
extern "C" {
__const unsigned short int **__wrap___ctype_b (void) {
return __ctype_b_loc();
}
}
You also apparently need to this option to the linking line: -Wl,--wrap,__ctype_b
Hope this helps...
I am getting the following error in my VC++ COM project. What is the problem in linking the lib files here?
Error 4 error LNK2019: unresolved external symbol _BVUOpen#8 referenced in function "unsigned int __stdcall AFunc(void *)" (?AFunc##YGIPAX#Z) CBillAcceptor.obj BillAcceptorCOM
Here are the explanation of the LNK2019 error : MSDN.
Look for a problem of definition about BVUOPen symbol ! The problem si inside the method AFunc Maybe, you haven't declare it correctly or haven't link the library or haven't export the symbol...
Probably, you need to link against some external library that contains the object code for the BVUOpen function. The name of that library is not obvious from your error message, but it should be possible to work out from the documentation you are coding from.