I am new to qt. I am using qt creator successfully to create ui. I need bluetooth functionality from qt. I had earlier version of code running through terminal. I copy pasted the running code. I get a lot of undefined references.
error: undefined reference to str2ba'
error: undefined reference tosqlite3_open'
error: undefined reference to sqlite3_errmsg'
error: undefined reference tosqlite3_errmsg'
error: undefined reference to sqlite3_free'
error: undefined reference tosqlite3_close'
error: undefined reference to hci_get_route'
error: undefined reference tohci_open_dev'
error: undefined reference to hci_inquiry'
error: undefined reference toba2str'
error: undefined reference to hci_read_remote_name'
error: undefined reference toba2str'
Is there anything like linux apis can not be used in qt? how to integrate the app then? Or do I have to link libraries like -lpthread -lbluetooth etc.
"Undefined reference..." seems to be a linker error.
Do you link against libsqlite3 and libbluetooth?
Adding
-lsqplite3 -lbluetooth
to your ld/g++ command line helps in that case
Related
I am using gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf on my ubuntu system using NetBeans IDE. My cross compiler is having libc-2.21 where as some of the libraries requires libc-2.28.And my target machine(debian jessie) do have libc-2.28 .
How can I upgrade it?
This is the error message I am getting after compiling in Netbeans:
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libavutil.so.56: undefined reference to 'fcntl64#GLIBC_2.28'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libsystemd.so.0: undefined reference to 'getrandom#GLIBC_2.25'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libbellesip.so.0: undefined reference to 'fcntl#GLIBC_2.28'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libavcodec.so.58: undefined reference to 'powf#GLIBC_2.27'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libsystemd.so.0: undefined reference to 'reallocarray#GLIBC_2.26'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libmediastreamer_voip.so.10: undefined reference to 'expf#GLIBC_2.27'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libpulsecommon-12.2.so: undefined reference to 'memfd_create#GLIBC_2.27'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libavcodec.so.58: undefined reference to 'exp2f#GLIBC_2.27'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libavcodec.so.58: undefined reference to 'log2f#GLIBC_2.27'
/opt/crosstool/arm-linux-gnueabihf/bin/../arm-linux-gnueabihf/libc/usr/lib/libortp.so.13: undefined reference to 'logf#GLIBC_2.27'
collect2: error: ld returned 1 exit status
I am writing a C++ application (based on Tensorflow Serving) in which I need to call Python and Numpy functions (from Python.h and numpy.h).
This application is built with Bazel.
So I include the header:
#include "tensorflow/python/lib/core/numpy.h"
which in turn includes Python.h.
This file seems to wrap numpy to fix an issue described in this Stack Overflow post.
Any other C++ code within the Tensorflow project which needs to make calls to Python.h also does not directly include it, but only includes tensorflow/python/lib/core/numpy.h. On the Bazel side, it seems to suffice to simply add //util/python:python_headers to the deps of the build.
My BUILD file looks like this:
...
cc_library(
name = "my_library",
srcs = ["my_library.cc"],
hdrs = ["my_library.h"],
deps = [
#org_tensorflow//util/python:python_headers",
#org_tensorflow//third_party/py/numpy:headers",
] + SOME_OTHER_DEPS + TENSORFLOW_DEPS + SUPPORTED_TENSORFLOW_OPS,
)
cc_binary(
name = "my_main",
srcs = ["my_main.cc"],
deps = [":my_library"],
)
...
Building the library with bazel build :my_library works fine.
Building the binary the same way does not work, I get the following errors:
bazel-out/local-fastbuild/bin/servable/_objs/my_library/servable/my:library.pic.o:my_library.cc:function tensorflow::serving::NumpyInitializer::init(): error: undefined reference to 'Py_Initialize'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::(anonymous namespace)::MakeArgTuple(tensorflow::(anonymous namespace)::PyCall*, _object**): error: undefined reference to 'PyList_New'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::(anonymous namespace)::MakeArgTuple(tensorflow::(anonymous namespace)::PyCall*, _object**): error: undefined reference to 'PyList_SetItem'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::(anonymous namespace)::MakeArgTuple(tensorflow::(anonymous namespace)::PyCall*, _object**): error: undefined reference to 'Py_BuildValue'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::(anonymous namespace)::IsSingleNone(_object*): error: undefined reference to 'PyType_IsSubtype'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::(anonymous namespace)::IsSingleNone(_object*): error: undefined reference to '_Py_NoneStruct'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::(anonymous namespace)::DoCallPyFunc(tensorflow::(anonymous namespace)::PyCall*): error: undefined reference to 'PyEval_CallObjectWithKeywords'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::(anonymous namespace)::DoCallPyFunc(tensorflow::(anonymous namespace)::PyCall*): error: undefined reference to 'PyErr_Occurred'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::(anonymous namespace)::DoCallPyFunc(tensorflow::(anonymous namespace)::PyCall*): error: undefined reference to 'PyErr_Print'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::(anonymous namespace)::DoCallPyFunc(tensorflow::(anonymous namespace)::PyCall*): error: undefined reference to 'PyList_Size'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::(anonymous namespace)::DoCallPyFunc(tensorflow::(anonymous namespace)::PyCall*): error: undefined reference to 'PyList_GetItem'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::(anonymous namespace)::DoCallPyFunc(tensorflow::(anonymous namespace)::PyCall*): error: undefined reference to 'PyType_IsSubtype'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::ConvertNdarrayToTensor(_object*, tensorflow::Tensor*): error: undefined reference to 'PyString_AsStringAndSize'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::ConvertTensorToNdarray(tensorflow::Tensor const&, _object**): error: undefined reference to 'PyString_FromStringAndSize'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::PyFuncOp::Compute(tensorflow::OpKernelContext*): error: undefined reference to 'PyGILState_Ensure'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/py_func_lib/external/org_tensorflow/tensorflow/python/lib/core/py_func.pic.o:py_func.cc:function tensorflow::PyFuncOp::Compute(tensorflow::OpKernelContext*): error: undefined reference to 'PyGILState_Release'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/numpy_lib/external/org_tensorflow/tensorflow/python/lib/core/numpy.pic.o:numpy.cc:function _import_array: error: undefined reference to 'PyImport_ImportModule'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/numpy_lib/external/org_tensorflow/tensorflow/python/lib/core/numpy.pic.o:numpy.cc:function _import_array: error: undefined reference to 'PyExc_ImportError'
bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/python/_objs/numpy_lib/external/org_tensorflow/tensorflow/python/lib/core/numpy.pic.o:numpy.cc:function _import_array: error: undefined reference to 'PyErr_SetString'
So there is obviously linking errors against Python.h. However, compiling any Tensorflow-internal goals works fine. I find it weird that it now can not link to Python.h even inside Tensorflow files.
After spending a few days looking into Tensorflow and their BUILD files I am out of ideas how to make this work.
So now I ask here: where and how exactly is the correct inclusion of Python defined in Tensorflow (and its Bazel files?).
Some clues seem to be in the definitions in util/python/BUILD and tensorflow/tensorflow.bzl.
There seems to be quite a bit of Bazel magic going on there.
You need to link your executable against libpython.(a|so). Your compile actions correctly made use of python.h and put some undefined symbols into objects. When building executable, linking action needs to resolve all undefined symbols, so it's no longer enough to have python.h, you need "python.cc".
My knowledge of tensorflow is rather poor, maybe somebody from the team can comment further if your use case is a solved problem. For general Bazel solution to "How to provide libpython" I'd recommend external repositories and their rules. I think this email thread will get you almost to the end.
Or you can copy the library over into your workspace and put it as a src to cc_binary rule.
I am trying to embed python in c++. I am not able to compile some c++ code that uses Python.h. I get an error that seems to be the library is not referenced correctly.
Below is the error shown which I received:
/tmp/ccxiQ8eE.o:(.data+0xc4): undefined reference to Py_NoopCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0xd4): undefined reference toPy_FilterPalletteCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0xe4): undefined reference to Py_FilterCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0xf4): undefined reference toPy_CaptureCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x104): undefined reference to Py_CaptureBufferCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x114): undefined reference toPy_StreamCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x1b4): undefined reference to Py_ModelDebugCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x1c4): undefined reference toPy_ModelVersionCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x1d4): undefined reference to Py_ModelSimRunCmd(_object*, _object*)'
/tmp/ccxiQ8eE.o:(.data+0x1e4): undefined reference toPy_ModelSimEndCmd(_object*, _object*)'
collect2: error: ld returned 1 exit status
make: *** [xgs_sim.linux] Error 1
For these functions prototype declaration has been done in some other test.h file and that file has been included while compiling in the program.cc file.
The function definition has been done in test.cc file.
Python version used is python 2.7.1.
Any help/guidelines will be much appreciated. Thanks.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am working on compiling a directory of c++ files and headers. I thought that I installed openGL, Glut and Glew properly but I keep getting referencing errors when running it.
Here is what I am doing and the errors that the compiler is sending back to me:
user#Linux-machine:~/Documents/HW$ make
g++ -g framework.o poly_line.o shader_program.o circle.o controller.o main.o scene.o view.o -lGLEW -lglut -lGLU -o HW
framework.cpp:84: error: undefined reference to 'glGetError'
check_gl.h:30: error: undefined reference to 'glGetError'
check_gl.h:43: error: undefined reference to 'glGetError'
poly_line.cpp:23: error: undefined reference to 'glGenBuffers'
poly_line.cpp:28: error: undefined reference to 'glBindBuffer'
poly_line.cpp:29: error: undefined reference to 'glBufferData'
poly_line.cpp:54: error: undefined reference to 'glEnable'
poly_line.cpp:55: error: undefined reference to 'glEnable'
poly_line.cpp:56: error: undefined reference to 'glBlendFunc'
poly_line.cpp:57: error: undefined reference to 'glHint'
poly_line.cpp:59: error: undefined reference to 'glDisable'
poly_line.cpp:60: error: undefined reference to 'glDisable'
poly_line.cpp:68: error: undefined reference to 'glBindBuffer'
poly_line.cpp:69: error: undefined reference to 'glEnableVertexAttribArray'
poly_line.cpp:70: error: undefined reference to 'glVertexAttribPointer'
poly_line.cpp:78: error: undefined reference to 'glDrawArrays'
poly_line.cpp:80: error: undefined reference to 'glDrawArrays'
shader_program.cpp:104: error: undefined reference to 'glCreateProgram'
shader_program.cpp:113: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:115: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:120: error: undefined reference to 'glGetProgramInfoLog'
shader_program.cpp:135: error: undefined reference to 'glGetShaderiv'
shader_program.cpp:137: error: undefined reference to 'glGetShaderiv'
shader_program.cpp:142: error: undefined reference to 'glGetShaderInfoLog'
shader_program.cpp:155: error: undefined reference to 'glDeleteShader'
shader_program.cpp:163: error: undefined reference to 'glDeleteShader'
shader_program.cpp:185: error: undefined reference to 'glCreateShader'
shader_program.cpp:195: error: undefined reference to 'glShaderSource'
shader_program.cpp:200: error: undefined reference to 'glCompileShader'
shader_program.cpp:214: error: undefined reference to 'glAttachShader'
shader_program.cpp:219: error: undefined reference to 'glLinkProgram'
shader_program.cpp:238: error: undefined reference to 'glUseProgram'
shader_program.cpp:249: error: undefined reference to 'glUniform1f'
shader_program.cpp:257: error: undefined reference to 'glUniform1i'
shader_program.cpp:270: error: undefined reference to 'glGetUniformLocation'
shader_program.cpp:290: error: undefined reference to 'glUseProgram'
shader_program.cpp:304: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:308: error: undefined reference to 'glGetProgramiv'
shader_program.cpp:315: error: undefined reference to 'glGetActiveUniform'
view.cpp:28: error: undefined reference to 'glClearColor'
view.cpp:29: error: undefined reference to 'glClear'
collect2: error: ld returned 1 exit status
make: *** [HW] Error 1
You have linked to everything but the kitchen sink in this example, but forgot about the OpenGL library itself.
Add GL to the list of libraries in your Makefile. Also, make sure that you link against it last.
Every time I make a new module and try to link it to my main class (Estudiant.o) using this line:
g++ -o red1.exe red1.o %OBJETOS_CPP%\Estudiant.o
I get this error:
red1.o:red1.cpp:(.text+0xd): undefined reference to
Estudiant::consultar_DNI() const' red1.o:red1.cpp:(.text+0x18):
undefined reference toEstudiant::Estudiant(int)'
red1.o:red1.cpp:(.text+0x25): undefined reference to
Estudiant::consultar_nota() const' red1.o:red1.cpp:(.text+0x74):
undefined reference toEstudiant::afegir_nota(double)'
red1.o:red1.cpp:(.text+0x83): undefined reference to
Estudiant::~Estudiant()' red1.o:red1.cpp:(.text+0xa3): undefined
reference toEstudiant::consultar_nota() const'
red1.o:red1.cpp:(.text+0xe5): undefined reference to
Estudiant::modificar_nota(double)' red1.o:red1.cpp:(.text+0x10b):
undefined reference toEstudiant::Estudiant()'
red1.o:red1.cpp:(.text+0x13a): undefined reference to
Estudiant::llegir_estudiant()' red1.o:red1.cpp:(.text+0x144):
undefined reference toEstudiant::te_nota() const'
red1.o:red1.cpp:(.text+0x182): undefined reference to
Estudiant::escriure_estudiant() const' red1.o:red1.cpp:(.text+0x18c):
undefined reference toEstudiant::~Estudiant()'
red1.o:red1.cpp:(.text+0x19f): undefined reference to
Estudiant::~Estudiant()'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe:
red1.o: bad reloc address 0x0 in section.ctors' collect2.exe: error:
ld returned 1 exit status
And I don't have the original Estudiant.cpp so I thought it might be because different compilers were used for compiling and for the link, but I reinstalled MinGW and I'm still getting this error.
I also tried to replace all the files and it didn't work.
I managed to get the source code of the Estudiant.o and compiled another version of it using the code and it worked. I don't know why the same code was compiled on two different machines and one worked and the other one didn't.