C++ Cassandra build error - c++

Hello i have a problem with building my code in c++.
I have installed cassandra on my Mac OS and all libraries that i need from datastax.
But when i build my test project i always get
Undefined symbols for architecture x86_64:
"_cass_cluster_free", referenced from:
_main in main.cpp.o
"_cass_cluster_new", referenced from:
_main in main.cpp.o
"_cass_cluster_set_contact_points", referenced from:
_main in main.cpp.o
"_cass_error_desc", referenced from:
_main in main.cpp.o
"_cass_future_error_code", referenced from:
_main in main.cpp.o
"_cass_future_free", referenced from:
_main in main.cpp.o
"_cass_session_connect", referenced from:
_main in main.cpp.o
"_cass_session_free", referenced from:
_main in main.cpp.o
"_cass_session_new", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
I know that i'm missing something in my CMakelist but i dont know exactly what
Here is my test code:
#include <cassandra.h>
#include <cstdio>
int main() {
/* Setup and connect to cluster */
CassCluster* cluster = cass_cluster_new();
CassSession* session = cass_session_new();
/* Add contact points */
cass_cluster_set_contact_points(cluster, "127.0.0.1");
/* Provide the cluster object as configuration to connect the session */
CassFuture* connect_future = cass_session_connect(session, cluster);
/* This operation will block until the result is ready */
CassError rc = cass_future_error_code(connect_future);
printf("Connect result: %s\n", cass_error_desc(rc));
/* Run queries... */
cass_future_free(connect_future);
cass_session_free(session);
cass_cluster_free(cluster);
return 0;
}

On MacOS the default installation directory is /usr/local with header files being installed in include and libraries being installed in lib. To ensure that the driver is installed properly you can compile your example code via clang++
clang++ <source_file_name> -o <executable_output> -lcassandra
To correct your issue with the CMake (CMakelists.txt) configuration you need to make sure that you use target_link_libraries(<target> cassandra) in order for your application to link against the driver library installed on your system.

Related

why is linking to libOpenCL.dylib failing with undefined symbol

I am trying to build the pocl library on MacOS
System:
MBP 16" 2019
Intel i9, AMD Radeon 5500m
Mac OS 12.4
using bash, instead of zsh
llvm from home-brew, -version 14
I have the following in my .bash_profile to setup the build environment
export PATH=/usr/local/opt/llvm/bin:$PATH
export CC=clang
export CMAKE_C_COMPILER=clang
export CXX=clang++
export CMAKE_CXX_COMPILER=clang++
I go and clone the repo with git, cd into the source directory, mkdir build
Then in build/ run:
cmake .. -DENABLE_TESTS=OFF -DENABLE_EXAMPLES=OFF -DENABLE_ICD=OFF
The config seems to work and then when I run make everything builds, and gets to the end but then gives me the following error:
[100%] Linking C executable poclcc
clang-14: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
Undefined symbols for architecture x86_64:
"_clBuildProgram", referenced from:
_main in poclcc.c.o
_poclu_load_program_multidev in libpoclu.a(misc.c.o)
"_clCreateCommandQueue", referenced from:
_poclu_get_any_device2 in libpoclu.a(misc.c.o)
_poclu_get_multiple_devices in libpoclu.a(misc.c.o)
"_clCreateContext", referenced from:
_main in poclcc.c.o
_poclu_get_any_device2 in libpoclu.a(misc.c.o)
_poclu_get_multiple_devices in libpoclu.a(misc.c.o)
"_clCreateContextFromType", referenced from:
_poclu_create_any_context in libpoclu.a(misc.c.o)
"_clCreateProgramWithBinary", referenced from:
_poclu_load_program_multidev in libpoclu.a(misc.c.o)
"_clCreateProgramWithIL", referenced from:
_poclu_load_program_multidev in libpoclu.a(misc.c.o)
"_clCreateProgramWithSource", referenced from:
_main in poclcc.c.o
_poclu_load_program_multidev in libpoclu.a(misc.c.o)
"_clGetDeviceIDs", referenced from:
_main in poclcc.c.o
_poclu_get_any_device2 in libpoclu.a(misc.c.o)
_poclu_get_multiple_devices in libpoclu.a(misc.c.o)
"_clGetDeviceInfo", referenced from:
_main in poclcc.c.o
_poclu_load_program_multidev in libpoclu.a(misc.c.o)
"_clGetPlatformIDs", referenced from:
_main in poclcc.c.o
_poclu_create_any_context in libpoclu.a(misc.c.o)
_poclu_get_any_device2 in libpoclu.a(misc.c.o)
_poclu_get_multiple_devices in libpoclu.a(misc.c.o)
"_clGetProgramBuildInfo", referenced from:
_main in poclcc.c.o
_poclu_show_program_build_log in libpoclu.a(misc.c.o)
"_clGetProgramInfo", referenced from:
_main in poclcc.c.o
_poclu_show_program_build_log in libpoclu.a(misc.c.o)
"_clReleaseContext", referenced from:
_main in poclcc.c.o
"_clReleaseProgram", referenced from:
_main in poclcc.c.o
ld: symbol(s) not found for architecture x86_64
I checked and libOpenCL.dylib was successfully built in the pocl/build/lib/CL/ directory. Just as a check, I tried compiling clinfo with a direct link to this library and it gave me the same set of error messages shown above.
Running nm libOpenCL.dylib | grep clBuildProgram prints the following:
0000000000013850 t _clBuildProgram
So its in there, but it is a local text section symbol. I don't actually know what that means though, and if that means it should work, or should not work. I don't actually understand what the problem is here or why this linking is failing, or what to do about it. Looking for some guidance on that.
The meaning of the lower case t is that the symbols are local, i.e. not externally visible to linking programs. Upper case T would be externally visible.
POCL has a number of configuration options, not all of which are documented in the Build section of the docs. The VISIBILITY_HIDDEN option is on by default unless the ENABLE_PROXY option is on.
In build/, running:
cmake .. -DENABLE_ICD=OFF -DVISIBILITY_HIDDEN=OFF
and then:
make
the compile succeeds to the end. Then in build/lib/CL/ running:
nm libOpenCL.dylib | grep clBuildProgram
now prints:
0000000000013790 T _clBuildProgram

How do I fix my current openGL error, my cmakelist may be my issue [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 10 months ago.
Improve this question
I have included the library <GLUT/glut.h> and all my syntax is correct, yet I am receiving this error.
Undefined symbols for architecture arm64:
"_glBegin", referenced from:
triangle(float*, float*, float*) in main.cpp.o
"_glClear", referenced from:
displayTriangle() in main.cpp.o
"_glClearColor", referenced from:
_main in main.cpp.o
"_glColor3f", referenced from:
drawTetrahedron(int) in main.cpp.o
"_glEnable", referenced from:
_main in main.cpp.o
"_glEnd", referenced from:
triangle(float*, float*, float*) in main.cpp.o
"_glFlush", referenced from:
displayTriangle() in main.cpp.o
"_glLoadIdentity", referenced from:
displayTriangle() in main.cpp.o
"_glMatrixMode", referenced from:
reshapeWindow(int, int) in main.cpp.o
"_glOrtho", referenced from:
reshapeWindow(int, int) in main.cpp.o
"_glVertex3fv", referenced from:
triangle(float*, float*, float*) in main.cpp.o
"_glViewport", referenced from:
reshapeWindow(int, int) in main.cpp.o
"_glutCreateWindow", referenced from:
_main in main.cpp.o
"_glutDisplayFunc", referenced from:
_main in main.cpp.o
"_glutInit", referenced from:
_main in main.cpp.o
"_glutInitDisplayMode", referenced from:
_main in main.cpp.o
"_glutInitWindowSize", referenced from:
_main in main.cpp.o
"_glutMainLoop", referenced from:
_main in main.cpp.o
"_glutPostRedisplay", referenced from:
reshapeWindow(int, int) in main.cpp.o
"_glutReshapeFunc", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
My cmakefile I feel like is my issue, but I have no idea where to begin.
Please provide more details like your relevant section of CMakeLists.txt for getting more info and getting quicker help from community.
Now, coming to the error logs, it seems you are cross-compiling the source files using a arm-based compilers.
The error message "ld: symbol(s) not found for architecture arm64" looks to me as a linker issue and you should be having the find_package() and linking calls in CMakeLists.txt for OpenGL.
So to start with , you should follow two steps initially and see if it solves your problem:
1. Make sure the CMake build system is pointing to correct compiler tool chain path (arm compilers in here).
Refer official website of CMake for same:
https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html
2. Make sure you are linking OpenGL
find_package(OpenGL REQUIRED)
target_include_directories(your_executable_name PUBLIC ${OPENGL_INCLUDE_DIR})
target_link_libraries(your_executable_name PUBLIC ${OPENGL_LIBRARIES})

compiling my code to use mongodb c driver in OSX via xcode

I am trying to make a C application on OSX(10.9.5) which will connect to mongodb and perform CRUD operations. I am using the release 1.3.5 which I downloaded from: https://github.com/mongodb/mongo-c-driver/releases/tag/1.3.5
I was sucessfully able to install mongo on my system. I am making my application which will use the library to perform CRUD operations. I am using Xcode 6.1.1 as my IDEon osx. I have given the appropriate path for header files in the ide and have no warnings or error before the run. I have given search path for dynamic libraries as well so I think linking should be happening fine as well. However when I try to run I get the following error:
Undefined symbols for architecture x86_64:
"_bson_as_json", referenced from:
_main in find.o "_bson_destroy", referenced from:
_main in find.o "_bson_free", referenced from:
_main in find.o "_bson_new", referenced from:
_main in find.o "_mongoc_cleanup", referenced from:
_main in find.o "_mongoc_client_destroy", referenced from:
_main in find.o "_mongoc_client_get_collection", referenced from:
_main in find.o "_mongoc_client_new", referenced from:
_main in find.o "_mongoc_collection_destroy", referenced from:
_main in find.o "_mongoc_collection_find", referenced from:
_main in find.o "_mongoc_cursor_destroy", referenced from:
_main in find.o "_mongoc_cursor_next", referenced from:
_main in find.o "_mongoc_init", referenced from:
_main in find.o ld: symbol(s) not found for architecture x86_64 clang:error: linker command failed with exit code 1 (use -v to see invocation)
Where am I going wrong?
Looks like you've specified the dynamic library path for libmongoc-1.0.so but not the library it depends on, libbson-1.0.so. Both libraries were installed when you built the driver, so you should be able to specify an additional path and your program will link correctly.

FTDI Chip ID on Mac OS Yosemite

I'm trying to get run Sample App from
http://www.ftdichip.com/Support/SoftwareExamples/FTDIChip-ID.htm
for Mac OS.
My problem is to get it compiled for Mac OS Yosemite.
I get this errors after "making" it :
ld: warning: ignoring file ./libftchipid.dylib, missing required architecture x86_64 in file ./libftchipid.dylib (2 slices)
Undefined symbols for architecture x86_64:
"_FTID_Constructor", referenced from:
_main in ChipID-3efebc.o
"_FTID_Destructor", referenced from:
_main in ChipID-3efebc.o
"_FTID_GetChipIDFromHandle", referenced from:
_main in ChipID-3efebc.o
"_FTID_GetDeviceChipID", referenced from:
_main in ChipID-3efebc.o
"_FTID_GetDeviceDescription", referenced from:
_main in ChipID-3efebc.o
"_FTID_GetDeviceSerialNumber", referenced from:
_main in ChipID-3efebc.o
"_FTID_GetDllVersion", referenced from:
_main in ChipID-3efebc.o
"_FTID_GetErrorCodeString", referenced from:
_main in ChipID-3efebc.o
"_FTID_GetNumDevices", referenced from:
_main in ChipID-3efebc.o
ld: symbol(s) not found for architecture x86_64
can someone help?
I have found the way how to read the ID without this library. it is written in EEPROM.
FT_ReadEE (ftHandle, 0x43, &wTemp)
(FT_ReadEE (ftHandle, 0x44, &wTemp)

C++ compile - GSL on x86_64

I am trying to compile the following code: http://www-personal.umich.edu/~mejn/dcbm/KLOptimization.cpp
But I get the following error message from g++:
> Undefined symbols for architecture x86_64: "_gsl_rng_uniform_int",
> referenced from:
> Initialize() in ccDEqovL.o
> _main in ccDEqovL.o "_gsl_rng_default_seed", referenced from:
> _main in ccDEqovL.o "_gsl_rng_default", referenced from:
> _main in ccDEqovL.o "_gsl_rng_alloc", referenced from:
> _main in ccDEqovL.o "_gsl_rng_name", referenced from:
> _main in ccDEqovL.o "_gsl_rng_get", referenced from:
> _main in ccDEqovL.o "_gsl_rng_uniform", referenced from:
> _main in ccDEqovL.o "ComputeVI()", referenced from:
> _main in ccDEqovL.o "ComputeNMI()", referenced from:
> _main in ccDEqovL.o "_gsl_rng_free", referenced from:
> _main in ccDEqovL.o ld: symbol(s) not found for architecture x86_64
I have MacBook Air, running iOS 10.7.3. g++ is i686-apple-darwin11-llvm-g++-4.2.
I installed GSL using "brew install gsl", which gave the following output:
==> Downloading http://ftpmirror.gnu.org/gsl/gsl-1.15.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gsl/1.15
==> make
==> make install
Warning: m4 macros were installed to "share/aclocal".
Homebrew does not append "/usr/local/share/aclocal"
to "/usr/share/aclocal/dirlist". If an autoconf script you use
requires these m4 macros, you'll need to add this path manually.
==> Summary
/usr/local/Cellar/gsl/1.15: 237 files, 7.0M, built in 81 seconds
It seems you forgot to link the GSL library. Just add the -lgsl and it should work (assuming gsl is in your library path).