While implementing mapView i am getting error - mkmapview

Undefined symbols for architecture i386: "_OBJC_CLASS_$_MKMapView"
Undefined symbols for architecture i386: "_OBJC_CLASS_$_MKMapView"

You have included the header, so you can compile your code, but you are not linking the binary library, so you can't complete the build process.
Follow these steps
-1.In your target settings, go to Build Phases
- 2.And in the "Link with binary libraries" section, add MapKit.framework .

Related

Why does/can my build access sysctl on Linux?

I inherited a C++ code with a dependency to OpenMPI that I want to delegate to Conan and CMake, and the automated build has a strange (to me at least) behavior related to sysctl that I want to understand.
How I tried to do it
I declared the required dependencies in my root CMakeLists.txt:
Note: I added the full list of requirements because I also suspect that some of them may be in conflict? That happened before with boost, that forced me to set explicitly zlib (if i remember correctly).
# stuff ...
conan_cmake_configure(
REQUIRES
zlib/1.2.12
mp-units/0.7.0
boost/1.79.0
openmpi/4.1.0
gsl/2.7
cspice/0067
GENERATORS
cmake
# that is required for cspice
CMakeDeps
CMakeToolchain
)
# more stuff ...
and then in the application CmakeLists.txt I find, include and link the executable to the required libraries:
add_executable(spock main.cpp)
find_package(cspice REQUIRED)
find_package(openmpi REQUIRED)
target_include_directories(
spock PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
openmpi_INCLUDE_DIRS
cspice_INCLUDE_DIRS
)
target_link_libraries(spock
CONAN_PKG::boost
CONAN_PKG::mp-units
openmpi::openmpi
cspice::cspice
)
# We need C++ 20 activated with the concepts library
target_compile_features(spock PUBLIC cxx_std_20)
Problem: undefined reference to sysctl ... on my local system only.
Building on my local machine with CMake 3.23.2 results in the following error message:
Consolidate compiler generated dependencies of target spock
[ 25%] Building CXX object src/CMakeFiles/spock.dir/main.cpp.o
^[[A^[[A[ 50%] Linking CXX executable ../bin/spock
/usr/bin/ld: /home/becheler/.conan/data/openmpi/4.1.0/_/_/package/8f7048d1bf6fc2a7985eb087c34e69a5e64f6c86/lib/libopen-pal.a(evutil_rand.o): in function `arc4_stir.isra.0':
evutil_rand.c:(.text+0x3d2): undefined reference to `sysctl'
collect2: error: ld returned 1 exit status
gmake[2]: *** [src/CMakeFiles/spock.dir/build.make:146: bin/spock] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:135: src/CMakeFiles/spock.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
However, the same build on Github workflows on Ubuntu 20.04 works. What is weird. The only difference before apart the distribution version is that github wokflows use higher privileges than me on local (I believe?).
What I tried so far
I've been trying to read about what this sysctlreference is. And I found conflicting information:
Frrom this man page:
The sysctl() function retrieves system information and allows processes with appropriate privileges to set system information.
this similar SO question came to the conclusion that
Linux does not support this function (other OS like MacOS or FreeBSD support it)
A comment from the same post concludes that in Linux,
these details can be obtained by reading the kernel-provided
pseudofiles /proc/cpuinfo and /proc/meminfo
So here is my question: why does it compile at all on the remote server if this command is not supposed to exist on the OS used?

Read Nifti image with ITK in C++

I am sorry if the question is primitive, but I can't figure the problem. I want to read nifti image in C++ using ITK libraries. I have used the code on Github: https://gist.github.com/rafamanzo/a3c258f4f74e898e9418. It is very simple code to read an image. Then I configured ITK into my project using CMake. The following is my CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8)
project(MyProject)
set(CMAKE_INSTALL_PREFIX "/home/itk")
set(ITK_DIR "/home/itk/InsightToolkit-4.13.0/bin/")
set(VTK_DIR "/home/vtk/VTK-8.1.0/bin/")
find_package(ITK REQUIRED)
find_package(VTK REQUIRED)
if (ITKVtkGlue_LOADED)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
else()
find_package(ItkVtkGlue REQUIRED)
include(${ItkVtkGlue_USE_FILE})
set(Glue ItkVtkGlue)
endif()
include(${ITK_USE_FILE})
include(${VTK_USE_FILE})
add_executable(MyProject mainFile.cxx)
target_link_libraries(MyProject ${ITK_LIBRARIES})
"cmake .." is ran successfully.
But "make all" gives me an error:
make[2]: *** No rule to make target '/home/vtk/VTK-8.1.0/bin/lib/libvtkRenderingOpenGL2.so', needed by 'MyProject'. Stop.
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/MyProject.dir/all' failed
make[1]: *** [CMakeFiles/MyProject.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
And surprisingly, when I build the project from Eclipse, I got another error:
./bin/CMakeFiles/feature_tests.o: In function `main':
/home/MyProject/Debug/../bin/CMakeFiles/feature_tests.c:34: multiple definition of `main'
makefile:32: recipe for target 'MyProject' failed
./bin/CMakeFiles/3.6.2/CompilerIdC/CMakeCCompilerId.o:/home/MyProject/Debug/../bin/CMakeFiles/3.6.2/CompilerIdC/CMakeCCompilerId.c:540: first defined here
/usr/bin/ld: cannot find -l/home/vtk/VTK-8.1.0/bin/lib/libvtkRenderingContextOpenGL2-8.1.so
collect2: error: ld returned 1 exit status
make: *** [MyProject] Error 1
I am pretty sure that configuring ITK is easy, especially I have done it before, but to use ImageFileReader only. Any help is much appreciated. Thank you.
Just to read an image you don't need VTKGlue part of ITK nor VTK itself. And the reported problem comes from VTK. If you want to keep VTK (to be used for something else?), you should fix it. Maybe you need to set VTK_RENDERING_BACKEND to OpenGL2 or something similar. Try building some VTK examples using your VTK to see if those examples build and run. That might point you more precisely to the problem.

Getting "undefined reference to" when using the lib for ARM, but not when compiling it

For one of my Qt Embedded projects I'm using a external Qt lib called SMTPEmail. This lib needs to be compiled before being included into a project, something that I managed to do successfully both for Qt 4.8 ARM and for Desktop.
The problem I'm getting is that when I include the headers into my project and include the library in the .pro, the linker gives me
(path_to_libs)/libSMTPEmail.so: undefined reference to `QSslSocket::connectToHostEncrypted(QString const&, unsigned short, QFlags<QIODevice::OpenModeFlag>)'
(path_to_libs)/libSMTPEmail.so: undefined reference to `QSslSocket::QSslSocket(QObject*)'
collect2: ld returned 1 exit status
make: *** [re8k_interface-tgt] Error 1
but only for compiling for ARM. IOW compiling the lib for both ARM and Desktop goes OK, compiling the project for Desktop using the lib goes OK but compiling it for ARM using the lib goes wrong.
Following this forum thread I suspected this could be due to missing the link to the library file of openssl (the project points to different lib folders when compiling for different environments). So I searched for all "openssl" related files inside the compiler for ARM (arm-arago-linux-gnueabi) and included in the same folder where the .so is located; same error. I then suspected the lib itself had other dependencies which were not in the path_to_libs, so I did a readelf -d libSMTPEmail.so and later in the .so.1 and readelf did return some lib dependencies that were not inside the same folder of the library. I then copied all such dependencies to the folder and got no success either.
So what could be happening? All dependencies known by me were put in place and I still get the error only for the situation where the lib is included by another project compiled for ARM.
You need to point your QMake where your libs and header file is in your .pro file;
So find where your library is assume /usr/local/include then ;
INCLUDEPATH += /usr/local/include
Add which libs you will use;
LIBS += -lSMTPEmail
You can check my answer here;
Two things stand out for me in your question:
1.
undefined reference to
This error message means that there was an error in the linking step of compilation. This occurs when you include a header to a function/class/variable but don't have the definition included in your own sources, or you do not link in a static library that does.
Searching for dependencies in libraries that are already compiled (.dll or .so) is too late, the compiler is looking for a static link, not a dynamic link.
2.
compiling the lib for both ARM and Desktop goes OK, compiling the
project for Desktop using the lib goes OK but compiling it for ARM
using the lib goes wrong.
This suggests that you are using conditional compilation in your .pro file that does a "both" compilation, a "desktop only" compilation and a "ARM only" compilation. If this is correct, you need to examine your compilation instructions for your "ARM only" compilation.
The error message itself refers to you using two functions from the QSslStock class. These are part of the QtNetwork module so you should have the following in your .pro file in order for the necessary links to be formed.
Qt += network

Duplicate Symbols in Phonegap Urbanairship Plugin for iOS

I am in the middle of integrating UA into my Phonegap/iOS application using the UA Phonegap plugin https://github.com/urbanairship/phonegap-ua-push.
Unfortunately, I can not get it to work. Even the sample project fails to build. The problem is a duplicate symbol during linking. Please note: i did not include any additional headers, libs, etc. I am just trying to build the iOS sample project.
The clashing symbol seems to be rooted in the ASI* (ASIHttpRequest, ASIAuthenticationDialog, etc) library, which has been integrated into UA. Surprisingly, the clashing happens between both UA libs (libUAirship-1.3.2.a and libUAirshipPush-1.3.2.a).
Linker output: ld: duplicate symbol _OBJC_METACLASS_$_UA_ASIAutorotatingViewController in /Users/b/Downloads/urbanairship-phonegap-ua-push-9b7a89b/ios-sample/Airship/libUAirshipPush-1.3.2.a(UA_ASIAuthenticationDialog.o) and /Users/b/Downloads/urbanairship-phonegap-ua-push-9b7a89b/ios-sample/Airship/libUAirship-1.3.2.a(UA_ASIAuthenticationDialog.o) for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How can this happen?
This issue appeared for me when I add the flag "-ObjC" in my target settings at "Other Linker Flags".
Check it, i need the flag for an another library but if it's not your case...

CMake finds the correct library, but VC++ attempts to link with something else

I have a CMake module to locate FreeGLUT:
FIND_PATH(FREEGLUT_INCLUDE_DIR NAMES GL/freeglut.h)
FIND_LIBRARY(FREEGLUT_LIBRARY NAMES freeglut freeglut_static)
SET(FREEGLUT_LIBRARIES ${FREEGLUT_LIBRARY})
SET(FREEGLUT_INCLUDE_DIRS ${FREEGLUT_INCLUDE_DIR})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FreeGLUT DEFAULT_MSG FREEGLUT_LIBRARY FREEGLUT_INCLUDE_DIR)
MARK_AS_ADVANCED(FREEGLUT_INCLUDE_DIR FREEGLUT_LIBRARY)
It works fine and locates freeglut_static.lib when I generate NMake Makefiles on Windows. I'm attempting to statically link FreeGLUT into my DLL:
FIND_PACKAGE(FreeGLUT REQUIRED)
ADD_LIBRARY(vti SHARED ${VTI_SOURCES})
ADD_DEFINITIONS("-DBUILD_VTI=1 -DFREEGLUT_STATIC=1")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${FREEGLUT_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(vti ${FREEGLUT_LIBRARIES})
My source code builds correctly, but when it gets to the linking stage, VC++ fails with:
LINK : fatal error LNK1104: cannot open file 'freeglut.lib'
Which is strange since freeglut.lib isn't mentioned anywhere that I can see in the generated NMake makefiles. It should be trying to link with freeglut_static.lib, which CMake locates and sets in FREEGLUT_LIBRARIES.
What might be causing this?
This is caused with pragma directives in FreeGLUT code (see freeglut_std.h). Using FREEGLUT_STATIC should really fix that for you, but I think you should pass it to CMake without quotes: ADD_DEFINITIONS(-DBUILD_VTI -DFREEGLUT_STATIC)

Resources