Qt 6 cmake - Linking 3rd party iOS SDK - ios

dyld[9260]: Library not loaded: #rpath/AdGemSdk.framework/AdGemSdk
Referenced from: <8989BF1B-622E-3F0E-B71C-CB327320532A> /private/var/containers/Bundle/Application/1D76ACFB-C91C-467B-A570-349462CE0127/Prankster.app/Prankster
Reason: tried: '/private/preboot/Cryptexes/OS#rpath/AdGemSdk.framework/AdGemSdk' (errno=2), '/System/Library/Frameworks/AdGemSdk.framework/AdGemSdk' (errno=2, not in dyld cache)
Reason: tried: '/private/preboot/Cryptexes/OS#rpath/AdGemSdk.framework/AdGemSdk' (errno=2), '/System/Library/Frameworks/AdGemSdk.framework/AdGemSdk' (errno=2, not in dyld cache)
I am doing the equivalent of this qmake (works):
INCLUDEPATH += $$PWD/Cpp/Native/ios/project/AdGemSdk.framework/Headers
LIBS += -F$$PWD/Cpp/Native/ios/project -framework AdGemSdk
adGemSdk.files = $$PWD/Cpp/Native/ios/project/AdGemSdk.framework
adGemSdk.path = Frameworks
QMAKE_BUNDLE_DATA += adGemSdk
Into this cmake:
# Native frameworks path
set(NATIVE_APPLE_FRAMEWORKS ${CMAKE_CURRENT_SOURCE_DIR}/Cpp/Native/ios/project)
target_include_directories(Prankster PRIVATE
${NATIVE_APPLE_FRAMEWORKS}/AdGemSdk.framework/Headers
)
# Copies all frameworks to .app frameworks folder
add_custom_command(TARGET Prankster PRE_LINK
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Release-iphoneos/Prankster.app/Frameworks
COMMAND ${CMAKE_COMMAND} -E copy_directory ${NATIVE_APPLE_FRAMEWORKS}/ ${CMAKE_CURRENT_BINARY_DIR}/Release-iphoneos/Prankster.app/Frameworks/
)
target_link_libraries(Prankster PRIVATE
"-framework AdGemSdk"
)
THING: all the frameworks are copied to the app folder and they are there. but the framework linking its what its failing somehow, as it does not appear on the linking output.
I don't know, i have been trying for a decent amount of time, qmake was much easier for this.
Thanks for your time.

Related

Can't link a project using cmake with OpenCV and LibTorch

I asked a similar question about linking a project with OpenCV a few days ago. I got that working, but now I've hit a very weird problem using CMake and adding LibTorch to the project.
If I only use OpenCV in the project, everything compiles, links, and runs fine.
But if I add Torch to CMakeLists.txt, I get a linker error:
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
set(CMAKE_VERBOSE_MAKEFILE ON)
project(torchscriptie)
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
find_package(Torch HINTS "/usr/local/libtorch")
message(STATUS "TORCH_LIBRARIES = ${TORCH_LIBRARIES}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
add_executable(torchscriptie main.cpp)
target_link_libraries( torchscriptie ${OpenCV_LIBS} )
target_link_libraries(torchscriptie "${TORCH_LIBRARIES}")
set_property(TARGET torchscriptie PROPERTY CXX_STANDARD 14)
This CMakeLists.txt file causes this error:
CMakeFiles/torchscriptie.dir/main.cpp.o: In function `main':
/code/cpp/torchscriptie/main.cpp:18: undefined reference to `cv::imread(std::string const&, int)'
/code/cpp/torchscriptie/main.cpp:24: undefined reference to `cv::namedWindow(std::string const&, int)'
/code/cpp/torchscriptie/main.cpp:25: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
collect2: error: ld returned 1 exit status
Here's the command:
/usr/bin/c++ -g -rdynamic CMakeFiles/torchscriptie.dir/main.cpp.o -o torchscriptie -Wl,-rpath,/usr/local/lib:/usr/local/libtorch/lib /usr/local/lib/libopencv_gapi.so.4.3.0 /usr/local/lib/libopencv_stitching.so.4.3.0 /usr/local/lib/libopencv_alphamat.so.4.3.0 /usr/local/lib/libopencv_aruco.so.4.3.0 /usr/local/lib/libopencv_bgsegm.so.4.3.0 /usr/local/lib/libopencv_bioinspired.so.4.3.0 /usr/local/lib/libopencv_ccalib.so.4.3.0 /usr/local/lib/libopencv_dnn_objdetect.so.4.3.0 /usr/local/lib/libopencv_dnn_superres.so.4.3.0 /usr/local/lib/libopencv_dpm.so.4.3.0 /usr/local/lib/libopencv_face.so.4.3.0 /usr/local/lib/libopencv_freetype.so.4.3.0 /usr/local/lib/libopencv_fuzzy.so.4.3.0 /usr/local/lib/libopencv_hdf.so.4.3.0 /usr/local/lib/libopencv_hfs.so.4.3.0 /usr/local/lib/libopencv_img_hash.so.4.3.0 /usr/local/lib/libopencv_intensity_transform.so.4.3.0 /usr/local/lib/libopencv_line_descriptor.so.4.3.0 /usr/local/lib/libopencv_quality.so.4.3.0 /usr/local/lib/libopencv_rapid.so.4.3.0 /usr/local/lib/libopencv_reg.so.4.3.0 /usr/local/lib/libopencv_rgbd.so.4.3.0 /usr/local/lib/libopencv_saliency.so.4.3.0 /usr/local/lib/libopencv_stereo.so.4.3.0 /usr/local/lib/libopencv_structured_light.so.4.3.0 /usr/local/lib/libopencv_superres.so.4.3.0 /usr/local/lib/libopencv_surface_matching.so.4.3.0 /usr/local/lib/libopencv_tracking.so.4.3.0 /usr/local/lib/libopencv_videostab.so.4.3.0 /usr/local/lib/libopencv_viz.so.4.3.0 /usr/local/lib/libopencv_xfeatures2d.so.4.3.0 /usr/local/lib/libopencv_xobjdetect.so.4.3.0 /usr/local/lib/libopencv_xphoto.so.4.3.0 /usr/local/libtorch/lib/libtorch.so /usr/local/libtorch/lib/libc10.so /usr/local/lib/libopencv_shape.so.4.3.0 /usr/local/lib/libopencv_highgui.so.4.3.0 /usr/local/lib/libopencv_datasets.so.4.3.0 /usr/local/lib/libopencv_plot.so.4.3.0 /usr/local/lib/libopencv_text.so.4.3.0 /usr/local/lib/libopencv_dnn.so.4.3.0 /usr/local/lib/libopencv_ml.so.4.3.0 /usr/local/lib/libopencv_phase_unwrapping.so.4.3.0 /usr/local/lib/libopencv_optflow.so.4.3.0 /usr/local/lib/libopencv_ximgproc.so.4.3.0 /usr/local/lib/libopencv_video.so.4.3.0 /usr/local/lib/libopencv_videoio.so.4.3.0 /usr/local/lib/libopencv_imgcodecs.so.4.3.0 /usr/local/lib/libopencv_objdetect.so.4.3.0 /usr/local/lib/libopencv_calib3d.so.4.3.0 /usr/local/lib/libopencv_features2d.so.4.3.0 /usr/local/lib/libopencv_flann.so.4.3.0 /usr/local/lib/libopencv_photo.so.4.3.0 /usr/local/lib/libopencv_imgproc.so.4.3.0 /usr/local/lib/libopencv_core.so.4.3.0 -Wl,--no-as-needed,/usr/local/libtorch/lib/libtorch_cpu.so -Wl,--as-needed /usr/local/libtorch/lib/libc10.so -lpthread -Wl,--no-as-needed,/usr/local/libtorch/lib/libtorch.so -Wl,--as-needed
I've tried a lot of different combination of commands, but I cannot figure our what's wrong.
When I echo the TORCH_LIBRARIES variable, it returns:
torch;torch_library;/usr/local/libtorch/lib/libc10.so
If I change the libaries, for example to torch_cpu, I'm able to link OpenCV libraries.
set(TORCH_LIBRARIES torch_cpu)
I have no idea why Torch libraries are causing link errors with OpenCV in the same project.
Any suggestions would be great.
Not sure if this fixes your problem, but I had also a few problems like yours. It is working for me with a cmake file including this:
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(MyProject)
set(CMAKE_CXX_STANDARD 14)
list(APPEND CMAKE_PREFIX_PATH "folderToLibtorch/libtorch/share/cmake")
find_package(Torch REQUIRED)
find_package(OpenCV REQUIRED)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lm -ldl")
add_executable(MyProject ...some project files...)
target_link_libraries(MyProject ${TORCH_LIBRARIES} ${OpenCV_LIBS})
set_property(TARGET MyProject PROPERTY CXX_STANDARD 14)
So make sure list(APPEND CMAKE_PREFIX_PATH "folderToLibtorch/libtorch/share/cmake") is included, this did the trick for me. Also take care to get the right libtorch version from pytorch maybe you should use the lower link and not the "pre-..." version.
Good Luck
The problem is in the version libtorch.
Please use libtorch-cxx11-abi-shared-with-deps not libtorch-shared-with-deps. It is library conflict between libtorch and opencv.
Solution here.
There is my version of CMakeList.txt with CUDA+LIBTORCH+OPENCV support:
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
SET(CUDA_HOME /usr/local/cuda)
SET(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)
SET(CUDA_TOOLKIT_ROOT_DIR /usr/local/cuda)
# SET(CUDA_CUBLAS_LIBRARIES /usr/local/cuda/lib64)
SET(CUDA_cublas_device_LIBRARY /usr/local/cuda/lib64)
# SET(CMAKE_CUDA_COMPILER_ENV_VAR /usr/local/cuda/bin/nvcc)
SET(CUDA_INCLUDE_DIRS /usr/local/cuda/include)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 50)
endif()
set(OpenCV_DIR /usr/local/lib/cmake/opencv4)
# set(OpenCV_DIR /usr/local/lib)
project(cmake_and_cuda LANGUAGES CXX CUDA)
include(CTest)
find_package(CUDA REQUIRED)
# libtorch with OpenCV support , with fixed BUG !
list(APPEND CMAKE_PREFIX_PATH ./libtorch)
find_package(Torch REQUIRED)
message(STATUS "TORCH_LIBRARIES = ${TORCH_LIBRARIES}")
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV_LIBS = ${OpenCV_LIBS}")
# ADD OWN CUDA FILES FOR BUILD LIBRARY.
add_library(particles_new_lib STATIC
torch_module_plus_cuda.cu
torch_module_plus_cuda.h
)
target_compile_features(particles_new_lib PUBLIC cxx_std_14)
# We need to explicitly state that we need all CUDA files in the
# particles_new_lib library to be built with -dc as the member functions
# could be called by other libraries and executables
set_target_properties( particles_new_lib
PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
add_executable(particle_cuda_test torch_and_cuda_call.cpp)
set_property(TARGET particle_cuda_test
PROPERTY CUDA_SEPARABLE_COMPILATION ON)
# LINK ALL LIBRARIES TO TARGET particle_cuda_test
target_link_libraries(particle_cuda_test PRIVATE ${TORCH_LIBRARIES} ${OpenCV_LIBS} particles_new_lib)
# LINK LIBRARIES
target_link_libraries(particle_cuda_test PRIVATE particles_new_lib)
set_property(TARGET particle_cuda_test PROPERTY CXX_STANDARD 14)

Mac OS CLion dyld: Library not loaded

That ERROR show:
dyld: Library not loaded: #rpath/libopencv_xphoto.3.1.dylib
Referenced from: /Users/zhilian/ClionProjects/untitled/cmake-build-debug/untitled
Reason: image not found
That is my CMakeLists.txt
cmake_minimum_required(VERSION 3.9)
project(untitled) #将untitled改为自己的工程名
find_package(OpenCV)
#或者find_package(OpenCV3)
include_directories( ${OpenCV_INCLUDE_DIRS} )
include_directories("/usr/local/Cellar/opencv/3.4.1_1/lib/")
link_directories(/usr/local/Cellar/opencv/3.4.1_1/lib/)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
add_executable(untitled ${SOURCE_FILES})
target_link_libraries( untitled ${OpenCV_LIBS} )
What setting should I change on CLion? setting DYLD_LIBRARY_PATH to environment variable doesn't work for me, I want to know what exactly happen when my app is running, it can compile successfully but run broken.

Library not found for -llib. (clang: error: linker command failed with exit code 1 (use -v to see invocation))

I am working on a project that was previously done and uploaded on app store.When I run this app in Xcode 5.0 it is working fine but when I run this on Xcode Version 5.1.1 (5B1008) I am getting Linker error on both device and simulator.
Error Message- Library not found for -llib. (clang: error: linker command failed with exit code 1 (use -v to see invocation)).
I have searched a lot but I didn't get any thread about Library not found for -llib error. Is there anything I have to change in build settings to resolve this?
Look at the linker command line in detail for the -L options being used:
Then use Terminal or Finder to see if your libXXX.a file exists in those directories. If the library exists elsewhere then you need to configure your Library Search Paths:
However there several details which you have not provided in your question when using a library within an app:
Is the library built as part of the Xcode project/workspace (as in the first image)?
Is the library supplied by a third-party with binary (.a) and header files (as in the second image)?
TL;DR: I ran make in the wrong directory so the paths were messed up.
Problem:
>make
linking ../build/release/yubikey-personalization-gui
/usr/x86_64-suse-linux/bin/ld: cannot find -llib
...
I ran into this when compiling the Yubikey Personalisation Tool. I tracked down the -llib call in my Makefile which looked like this:
...
LINK = #echo linking $# && g++
...
LIBS = $(SUBLIBS) -L/usr/lib64 -L../lib/release -llib -lyubikey -lykpers-1 -lQtGui -L/usr/lib64 -L/usr/X11R6/lib -lQtCore -lpthread
...
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
So it was setting a variable called LINK which would print "linking" and then call g++, which is the compiler.
Then it set the var LIBS which would hold the ominous -llib.
Then it composes and runs the command $(LINK) ... $(LIBS).
Which runs g++ with the parameter -llib.
And what does that do? Turns out -l<something> is telling the compiler to use the something-library. So it asks for the library called lib here. Which is strangely generic. I figured out that the sources came with a directory called lib/, which was at ../lib.
So starting make from a directory higher up fixed it.
You should remove libstdc++ from other linker flags in your xcode project
https://stackoverflow.com/a/53103383/1344237

Linker can not find OpenCV libraries when using CMake

I have a copy of OpenCV2.4.0 installed in /usr/local/lib
My program compiled properly but when the linker is evoked, it gave errors such as:
/home/zhouw/moos-ivp-zhouw/trunk/src/pATRTest/mst.cpp:661: undefined reference to 'cv::_OutputArray::_OutputArray(cv::Mat const&)'
CMakeFiles/pATR.dir/mst.cpp.o:/home/zhouw/moos-ivp-zhouw/trunk/src/pATRTest/mst.cpp:675: more undefined references to `cv::_OutputArray::_OutputArray(cv::Mat const&)'
collect2: ld returned 1 exit status
make[2]: *** [../bin/pATR] Error 1
make[1]: *** [src/pATRTest/CMakeFiles/pATR.dir/all] Error 2
make: *** [all] Error 2
The strange thing is my program uses opencv intensively, if CMake has trouble finding the libraries, it should have complained a lot more undefined references than jsut a few.
I tried adding
LINK_DIRECTORIES("/usr/local/lib") in my cmake file but it didn't help.
There's another library called POCO is also installed under /usr/local/lib. My program also links to the POCO libraries, but CMake seems having no trouble finding them.
If I manually link with -L/usr/local/lib, it would link properly without error.
The CMakeLists.txt looks like this
PROJECT(pATR)
#what files are needed?
SET(SRCS
spline.hpp
utils.hpp utils.cpp
mst.hpp mst.cpp
cluster.hpp cluster.cpp
target.hpp target.cpp
detector.hpp detector.cpp
classifier.hpp classifier.cpp
atr.hpp atr.cpp
MOOSAtr.h MOOSAtr.cpp
main.cpp
)
ADD_EXECUTABLE(pATR ${SRCS})
# indicate how to link
#LINK_DIRECTORIES("/usr/local/lib")
TARGET_LINK_LIBRARIES(pATR opencv_core opencv_highgui opencv_imgproc MOOS)
INSTALL(TARGETS
pATR
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)
Any idea what's going on? Many thanks!
If you have CMake 2.8, I recommend using find_package(OpenCV) to load the libraries.
There is an example at http://docs.opencv.org/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html
The CMake file:
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
You're after:
find_package(OPENCV COMPONENTS core imgproc highgui REQUIRED)
From the docs:
Packages with components
Some libraries are not monolithic, but come with one or more dependent
libraries or components. A notable example for this is the Qt library,
which ships (among others) with the components QtOpenGL and QtXml. To
use both of these components, use the following the find_package
command:
find_package(Qt COMPONENTS QtOpenGL QtXml REQUIRED)
also, for more info you may check out the following link.
https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/How-To-Find-Libraries
I am not sure if it makes sense that CMake can't find the linking libraries. CMake finds your dependencies and generates the Makefile, but it doesn't actually compile and link for you.
Your error are not from CMake, right? They are from make.
I always link manually with this
g++ -o myopencvapp `pkg-config --cflags --libs opencv` myopencvapp.cpp`
when invoking g++.

How to build ohNet for iOS?

I am trying to build the ohNet UPnP stack from openhome.org for execution on the iPhone and iPhoneSimulator. I have seen in various places on the web that there is a port to iOS, and indeed there is some reference to iOS building in the Makefile. After some editing of the $DEVROOT and $SDKROOT paths, I can compile many of the sources, but the build halts with error at:
g++ -pthread -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/ -arch armv6 -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/usr/lib/system -shared -shared-libgcc -o Build/Obj/Mac/arm/Release/libohNet.dylib Build/Obj/Mac/arm/Release/Ascii.o Build/Obj/Mac/arm/Release/AsyncC.o Build/Obj/Mac/arm/Release/AsyncPrivate.o Build/Obj/Mac/arm/Release/Bonjour.o Build/Obj/Mac/arm/Release/Buffer.o Build/Obj/Mac/arm/Release/Discovery.o Build/Obj/Mac/arm/Release/Debug.o Build/Obj/Mac/arm/Release/Converter.o Build/Obj/Mac/arm/Release/CpDeviceCore.o Build/Obj/Mac/arm/Release/CpDeviceC.o Build/Obj/Mac/arm/Release/CpDeviceStd.o Build/Obj/Mac/arm/Release/CpDeviceDvCore.o Build/Obj/Mac/arm/Release/CpDeviceDvStd.o Build/Obj/Mac/arm/Release/CpDeviceDvC.o Build/Obj/Mac/arm/Release/CpDeviceUpnpCore.o Build/Obj/Mac/arm/Release/CpDeviceUpnpC.o Build/Obj/Mac/arm/Release/CpDeviceUpnpStd.o Build/Obj/Mac/arm/Release/CpiDevice.o Build/Obj/Mac/arm/Release/CpiDeviceDv.o Build/Obj/Mac/arm/Release/CpiDeviceUpnp.o Build/Obj/Mac/arm/Release/CpiService.o Build/Obj/Mac/arm/Release/CpiStack.o Build/Obj/Mac/arm/Release/CpiSubscription.o Build/Obj/Mac/arm/Release/CpProxy.o Build/Obj/Mac/arm/Release/CpProxyC.o Build/Obj/Mac/arm/Release/CpServiceC.o Build/Obj/Mac/arm/Release/DvDevice.o Build/Obj/Mac/arm/Release/DvDeviceStd.o Build/Obj/Mac/arm/Release/DvDeviceC.o Build/Obj/Mac/arm/Release/DviDevice.o Build/Obj/Mac/arm/Release/DvInvocationC.o Build/Obj/Mac/arm/Release/DvInvocationStd.o Build/Obj/Mac/arm/Release/DviProtocolUpnp.o Build/Obj/Mac/arm/Release/DviProviderSubscriptionLongPoll.o Build/Obj/Mac/arm/Release/DvOpenhomeOrgSubscriptionLongPoll1.o Build/Obj/Mac/arm/Release/DviServer.o Build/Obj/Mac/arm/Release/DviServerUpnp.o Build/Obj/Mac/arm/Release/DviServerWebSocket.o Build/Obj/Mac/arm/Release/DviService.o Build/Obj/Mac/arm/Release/DviStack.o Build/Obj/Mac/arm/Release/DviSubscription.o Build/Obj/Mac/arm/Release/DviPropertyUpdateCollection.o Build/Obj/Mac/arm/Release/DvProvider.o Build/Obj/Mac/arm/Release/DvProviderC.o Build/Obj/Mac/arm/Release/DvServerUpnp.o Build/Obj/Mac/arm/Release/DvServerUpnpC.o Build/Obj/Mac/arm/Release/DeviceXml.o Build/Obj/Mac/arm/Release/Error.o Build/Obj/Mac/arm/Release/EventUpnp.o Build/Obj/Mac/arm/Release/Exception.o Build/Obj/Mac/arm/Release/Fifo.o Build/Obj/Mac/arm/Release/Http.o Build/Obj/Mac/arm/Release/DNSCommon.o Build/Obj/Mac/arm/Release/DNSDigest.o Build/Obj/Mac/arm/Release/mDNS.o Build/Obj/Mac/arm/Release/uDNS.o Build/Obj/Mac/arm/Release/MdnsPlatform.o Build/Obj/Mac/arm/Release/MdnsProvider.o Build/Obj/Mac/arm/Release/Maths.o Build/Obj/Mac/arm/Release/Md5.o Build/Obj/Mac/arm/Release/NetworkAdapterList.o Build/Obj/Mac/arm/Release/Network.o Build/Obj/Mac/arm/Release/Parser.o Build/Obj/Mac/arm/Release/Printer.o Build/Obj/Mac/arm/Release/ProtocolUpnp.o Build/Obj/Mac/arm/Release/Queue.o Build/Obj/Mac/arm/Release/RefCounter.o Build/Obj/Mac/arm/Release/Service.o Build/Obj/Mac/arm/Release/ServiceC.o Build/Obj/Mac/arm/Release/sha1.o Build/Obj/Mac/arm/Release/Ssdp.o Build/Obj/Mac/arm/Release/SsdpDv.o Build/Obj/Mac/arm/Release/Stack.o Build/Obj/Mac/arm/Release/Stream.o Build/Obj/Mac/arm/Release/Subscription.o Build/Obj/Mac/arm/Release/Thread.o Build/Obj/Mac/arm/Release/Timer.o Build/Obj/Mac/arm/Release/Uri.o Build/Obj/Mac/arm/Release/XmlParser.o Build/Obj/Mac/arm/Release/XmlFetcher.o Build/Obj/Mac/arm/Release/OhNet.o Build/Obj/Mac/arm/Release/OhNetCp.o Build/Obj/Mac/arm/Release/OhNetDv.o Build/Obj/Mac/arm/Release/OhNetCombined.o Build/Obj/Mac/arm/Release/OhNetC.o Build/Obj/Mac/arm/Release/OhNetCCp.o Build/Obj/Mac/arm/Release/OhNetCDv.o Build/Obj/Mac/arm/Release/OhNetCCombined.o Build/Obj/Mac/arm/Release/OsWrapper.o Build/Obj/Mac/arm/Release/Os.o
llvm-g++-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/arm-apple-darwin11-llvm-g++-4.2': execvp: No such file or directory
make: *** [ohNetDll] Error 255
I cannot understand why the build process wants to build ohNetDll for this platform, nor how to opt out of that section/target. Dynamic libraries are not supported for iOS Apps and certainly not dlls which are native to Windows.
If you have built/ported/used ohNet on iOS can you please advise how to do it? I wanted to post this question on the ohNet forum, but I am unable to register (because I haven't submitted a security question even though there is nowhere to do so on the form!).
The source, documentation and API guide all look very promising for ohNet, so I am hoping you can advise...
"After some editing of the $DEVROOT and $SDKROOT paths, I can compile
many of the sources..."
For iPhoneOS Platform, set the following environment variables.
export ROOTDIR="/Applications/Xcode.app/Contents/Developer"
export PLATFORM="iPhoneOS"
export MAX_VERSION="5.1"
export DEVROOT=${ROOTDIR}/Platforms/${PLATFORM}.platform/Developer
export SDKROOT=${DEVROOT}/SDKs/${PLATFORM}${MAX_VERSION}.sdk
Then, in the root directory of the source, in the file "Makefile", locate the following section and ensure it looks the same as this one:
ifeq ($(MACHINE), Darwin)
ifeq ($(mac-arm),1)
# Darwin, ARM -> iOS
platform ?= iOS
linkopts_ohNet =
devroot=$(DEVROOT)
sdkroot=$(SDKROOT)
platform_cflags = -I$(sdkroot)/usr/lib/gcc/arm-apple-darwin10/4.2.1/include/ -I$(sdkroot)/usr/include/ -I/usr/bin/arm-apple-darwin10-gcc -miphoneos-version-min=2.2 -pipe -no-cpp-precomp -isysroot $(sdkroot) -DPLATFORM_MACOSX_GNU -DPLATFORM_IOS -I$(sdkroot)/usr/include/c++/4.2.1/armv6-apple-darwin10/
# It seems a bit weird that iOS uses a sub-dir of Build/Obj/Mac, is that deliberate? --AW
osbuilddir = Mac/arm
objdir = Build/Obj/Mac/arm/$(build_dir)/
platform_linkflags = -L$(sdkroot)/usr/lib/ -arch armv7 -L$(sdkroot)/usr/lib/system
compiler = $(devroot)/usr/bin/llvm-gcc-4.2 -arch armv7 -isysroot $(SDKROOT) -o $(objdir)
# No support for linking Shared Objects for ARM MAC
# link = $(devroot)/usr/bin/llvm-gcc-4.2 -pthread -Wl $(platform_linkflags)
ar = $(devroot)/usr/bin/ar rc $(objdir)
native_only = yes
The key points here are:
The $DEVROOT and $SDKROOT are correct for your version of the iOS SDK.
The variable $native_only is set to yes. This avoids error and early exit when make tries (and inevitably fails) to build ohNetDll on the Mac host machine.
Then, in a terminal, in the source root directory (i.e the one containing Makefile) type:
make mac-arm=1
Hope this helps...
Doug

Resources