Compile OpenGL in emscripten - c++

I'm trying to compile an OpenGL game for Webassembly using emscripten.
However, when linking the code, I receive the following undefined symbols messages:
wasm-ld: error: undefined symbol: glGetTexImage
wasm-ld: error: undefined symbol: gluErrorString
I have already checked that I'm linking with "glut", "GLU" and "GL".

Related

qt error: undefined reference to `str2ba'

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

Linking errors when using Tensorflow/Bazel to call Python from C++

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.

Timersub and timeradd on AIX

I'm fairly new to the AIX platform. Currently porting an application from linux to AIX.
I know timeradd and timersub aren't supported on AIX which is why I get the following error:
ld: 0711-317 ERROR: Undefined symbol: .timeradd
ld 0711-317 ERROR: Undefined symbol: .timersub
ld 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
Is there a workaround? Or a patch for the definitions?

undefined reference to `sqlite3_open'

I am trying to follow some sqlite C++ tutorial to be able to access a database from within C++ code on Linux. sqlite3 is installed and working, but when I try to compile the example code given on the link (Create a Table) I get the following error:
g++ build/test.o -o bin/test -pthread -L lib
build/test.o: In function `main':
/home/alexander/Projects/Test/src/test.cpp:22: undefined reference to `sqlite3_open'
/home/alexander/Projects/Test/src/test.cpp:24: undefined reference to `sqlite3_errmsg'
/home/alexander/Projects/Test/src/test.cpp:39: undefined reference to `sqlite3_exec'
/home/alexander/Projects/Test/src/test.cpp:42: undefined reference to `sqlite3_free'
/home/alexander/Projects/Test/src/test.cpp:46: undefined reference to `sqlite3_close'
collect2: error: ld returned 1 exit status
Do I need to install something else? Or do I need to set some paths?
I have no practice in compiling straight from the shell.
In CodeBlocks it is necessary to point the paths of the “sqlite3.h” header and the “libsqlite3.so” dll.
If the dll is not specified in Linker Settings, exactly the mentioned problem occurs.

How to use decimal floating point in Gnu C++ (g++)?

GCC 4.5 added support for decimal floating points in the runtime library (http://gcc.gnu.org/gcc-4.5/changes.html). I'm able to compile code including , using namespace std::decimal, then using decimal64 and so on in the code.
Unfortunately, I'm missing some library for linking the code. I've not been able to find out which libraries should be required. DFP support is enabled in gcc (--enable-decimal-float=dpd)
Additionally, should there be some fast way of providing decimal literals in the code? By fast, I mean user defined literals that are handled by templates and translated at compile time. I do not want to provide doubles that are converted at runtime (despite performance and the fact that I really can't stand moving evaluations from compile time to runtime there are still rounding issues...). I've already found the suffix "df" but that does not seem to be recognized by the compiler.
I'm using gcc version 4.7.1 on target powerpc-ibm-aix7.1.0.0.
Linker error messages:
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatsisd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatsidd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatsitd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_mulsd3
ld: 0711-317 ERROR: Undefined symbol: .__dpd_muldd3
ld: 0711-317 ERROR: Undefined symbol: .__dpd_multd3
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatdisd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatunsdisd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatdidd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatunsdidd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatditd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatunsditd
TIA.
I've recently compiled gcc4.7.1 from source and had trouble with missing symbol __floatunsidf. This turned out to be a symbol required by libstdc++.so and defined in libgcc_s.so. Given that both Libraries are provided by gcc they should be compatible. In my case i still had a linker include to an old version of libgcc_s that i'd lifted from my target platform. Its probably worth doing
# to find out where libstdc++.so is:
gcc -print-file-name=libstdc++.so
# see if it references the symbol you're missing
readelf -a "path to libstdc++.so" | grep "symbol name"
and then doing the same for libgcc_s to see if they both define the symbol you are missing. Nb one will mark the symbol as undefined - thats how the linker knows its required.