Solving a difficult compilation issue - osx-mavericks

Good day,
First up, I have a mac running Mavericks, and I am attempting to build PCL (Point Cloud Library) as part of ROS.
This is the command that fails:
cd /Users/X/ros_catkin_ws/build_isolated/pcl_ros && /Users/X/ros_catkin_ws/install_isolated/env.sh cmake -vd /Users/X/ros_catkin_ws/src/perception_pcl/pcl_ros -DCATKIN_DEVEL_PREFIX=/Users/X/ros_catkin_ws/devel_isolated/pcl_ros -DCMAKE_INSTALL_PREFIX=/Users/X/ros_catkin_ws/install_isolated -DCMAKE_BUILD_TYPE=Release
With:
CMake Error at /usr/local/share/pcl-1.8/PCLConfig.cmake:47 (message):
simulation is required but glew was not found
Call Stack (most recent call first):
/usr/local/share/pcl-1.8/PCLConfig.cmake:500 (pcl_report_not_found)
/usr/local/share/pcl-1.8/PCLConfig.cmake:663 (find_external_library)
CMakeLists.txt:8 (find_package)
Now, I have done what I can to debug this. Looking up online, I notice this is happening due to the fact that in Mavericks, there is no longer the GLEW.framework
https://github.com/PointCloudLibrary/pcl/issues/492
Hence, I installed it via brew, and yet I still get the same issue. Now, I'm thinking, perhaps cmake cannot find it, so I created my own cmake project, and attempted to add find_package(glew). It seems to have found the package here:
-- Found GLEW: /usr/local/include
Hence, I included /usr/local/include in my $PATH variable. Yet once again, it seems to fail with the same error. I am kind of at a lost here, and am not sure how to continue.
I am speculating that in the command above, it seems that somehow the env.sh there seems to change the environmental variables such that it can't find glew.
Any thoughts?
EDIT:
More absurdity. I create a CMake file and included find_package(PCL). It works perfectly. WTF? It even says it found glew
Found Glew: -framework GLEW;-framework Cocoa
How come it works in my Cmake file, but not in theirs? What might cause this

Bastards. I went to the pcl_ros folder, and the glew include directory was pointing to Glew.Framework, which is deprecated as of OSX 10.8!
Scumbag Mavericks! I simply pointed it to the correct glew include directory, which for me is:
/usr/local/Cellar/glew/1.11.0/include/GL

Same as user ovfstack described encountered on OS X 10.10. While compiling ros indigo I found that /usr/local/share/pcl-1.8/PCLConfig.cmake is deprecated.
I installed glew via homebrew under /usr/local/Cellar/glew/1.11.0/include/ and changed line 415 in the above mentioned cmake file from
/System/Library/Frameworks/GLEW.framework/Versions/A/Headers
to
/usr/local/Cellar/glew/1.11.0/include/
Now it compiles just fine.

Related

Can't compile App from Titanium Appcelerator with iOS OpenCV Module

I have an issue that is going on for over a month and I can't find any solution for it.
I created an Appcelerator Titanium Module, which uses the OpenCV framework.
I tried literally everything I found on the internet to make it work, but no sucess.
The module compiles, but it crashes when building the App that uses it.
To dig deep in the problem, I compile the App via CLI using appc run -p ios -l trace to see the whole thing. This is what I get:
[TRACE] ld: framework not found opencv2 [TRACE] clang: error: linker command failed with exit code 1 (use -v to see invocation)
This happens if I declare the framework in the module.xconfig file, like this:
OTHER_LDFLAGS=$(inherited) -framework opencv2
If I don't declare it in the file, I get:
[TRACE] symbols not found for architecture x86_64 [TRACE] clang: error: linker command failed with exit code 1 (use -v to see invocation)
Well, the opencv2.framework file is inside the /ios folder in the module.
This is what I tried so far, to put the OpenCV Framework in the project:
OpenCV Official Example for XCode
Compiling it from scratch and then adding to the Project
brew install opencv and then adding it to the project
I configured Framework Search Paths like this:
$(inherited) $(PROJECT_DIR) $(SRCROOT)
Header Search Paths like this:
$(inherited) "$(TITANIUM_SDK)/iphone/include" /usr/local/Cellar/opencv/4.4.0/include (this last one, when installed by brew CLI command.
The Other Linker Flags, is configured like this:
This configuration I got from this tutorial: OpenCV on XCode
And finally, I tried adding the .dylib files from the source of the OpenCV Framework in the project by right-clicking the project's name and Add Files.
So, I tried everything I could find to solve it, but I can't get it to work.
Sorry for the long question, but I am completly out of ideas on how to make this work.
Please, help me!
First of all, the opencv2.framework is copied automatically to the XCode /ios folder (if you selected Copy Files if Needed). BUT, Appcelerator needs 3rd party frameworks to be put on /ios/platform folder. So, I moved it there.
Secondly I added -lz to the Other Linker Flags in Build Settings.
This solved the problem. I must thank the team and developers from TiSlack (An Appcelerator platform community), which helped me through this. Michael and Hans, Thanks!
Here is a video that helped me install OpenCV4 on my Macbook Pro Mojave 10.14.6. I tried installing OpenCV using another video and it led me to getting a linker error that was similar to yours.
Basically, the problem was the path I specified as for my /lib and /include folders.
https://www.youtube.com/watch?edufilter=NULL&v=HxNZEa7Slyk

After running make, get 'no rule to make target' error when looking for openGL framework after updating macOS and xcode

I have come back to working on a school project after a short hiatus. However, I can't get it to build anymore. We were provided with the following cmake file:
cmake_minimum_required(VERSION 2.8)
PROJECT(astro)
SET(VTK_DIR /Users/hank/Hartree/VTK/install/lib/cmake/vtk-6.0)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
add_executable(astro MACOSX_BUNDLE astro)
SET(CMAKE_CXX_LINK_FLAGS "-framework OpenGL")
if(VTK_LIBRARIES)
target_link_libraries(astro ${VTK_LIBRARIES})
else()
target_link_libraries(astro vtkHybrid)
endif()
After running cmake and trying to compile the project with make, I get the following error:
*** No rule to make target >'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Deve>loper/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenGL.framework', >needed by 'astro.app/Contents/MacOS/astro'. Stop.
I think I updated my os and xcode during my break from the project, and that caused the issue. I don't know a whole lot about cmake or makefiles, but I think that somehow the path to openGL is getting messed up. Poking through my file system I have found the paths
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk,
and
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk,
and I have been able to find the OpenGL frameworks in those directories, but there is no MacOSX10.12.sdk directory.
I found the following similar questions here and here. However, I have not been using Qt, and when I run xcode-select -pit prints the correct path /Applications/Xcode.app/Contents/Developer
Any ideas how to fix this?
I received exactly the same error when installing an application from source code. I solved this problem by duplicate the "MacOSX10.13.sdk" directory in
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
and rename it "MacOSX10.12.sdk".
I am not an expert in MacOSX or cmake, therefore my answer may not be the best solution and may even cause problems, but it does solve this problem for me. If anyone knows the correct way to do, I'd like to know it.
Here are what I tried:
At beginning, cmake can not find "CMAKE_OSX_SYSROOT" after configuration.
I first changed the cmake settings to
CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.12
CMAKE_OSX_SYSROOT:STRING=macosx10.13
but this does not work. Same error.
Then I updated my Mac to MacOSX 10.13 High Sierra. This time cmake can correctly set
CMAKE_OSX_SYSROOT:PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk
but still generates the same error. Therefore I believe the problem comes from the application source code.
I googled how to install MacOSX10.12.sdk and find this post:SDKs.
The easiest way may be finding the old sdk from TimeMachine. But I just bought my Mac and it doesn't have the old version sdk. Therefore I simply duplicate and rename the sdk to try, and it works. I think putting the sym link of the real MacOSX10.12.sdk in the folder will be the best solution to this problem.

Library not found OpenCV

I'm on mac 10.7.5, using xcode 4.6.2 and working with the OpenCV 2.4.3 library. I went through the process of making the build directory with the cmake files in terminal and did the download.
I added the .dylib files in Xcode and changed the header path, changed C++ Library to libstdc++, but when I compiled I got this error :
ld: library not found for -lopencv_calib3d.2.4.3
clang: error: linker command failed with exit code 1
I have libopencv_calib3d.2.4.3.dylib added in the project so I have no idea what else it needs.Any ideas?
If your "make back-end" is Cmake you should stick to using it. Local config changes in Xcode can "secretly" be overwritten when the cmake is rerun (which for example happens after you make changes to it) creating weird build errors and forcing you to remember all the manual changes you made.
Your problem seems to be that the generated project doesn't seem to know where to look for opencv.
Assuming you installed opencv using macports you should add a line saying
link_directories(/opt/local/lib)
to your CMakeLists.txt. (if you installed it using brew, or compiled it manually just replace /opt/local/lib for /usr/local/lib or the path to your compiled libraries)
Also make sure to link against opencv_calib3d instead of opencv_calib3d.2.4.3 (unless you have a very particular reason for bypassing this, but that usually means that something else is weird in the setup :) )
Final pointer that you might already know of: As you are already using Cmake you should add the libraries to link against using TARGET_LINK_LIBRARIES(...) in Cmake rather than manually adding them in Xcode (referring to my previous argument).

Compiling cvblob on OSX does not correctly locate OpenCV libs

I'm having issues with CVBlob locating the OpenCV installation on OSX 10.6. I have patch for the osx install as described in an earlier message on the cvblob wiki. When I run make, the build process immediately complains that it cannot find cv.h or highgui.h and then subsequently fails to locate additional symbols and vars declared in those headers.
The cmake command I am using is :
cmake -DOpenCV_DIR=/usr/local/Cellar/opencv/2.3.1a/ .
I can see that cv.h is contained in the includes directory in that location. I also tried the following cmake command where I specify the location of the OpenCV Cmake info:
cmake -DOpenCV_DIR=/usr/local/share/OpenCV/ .
Neither seems to correctly tell the cvblob installation where OpenCV is located.
Please help!
SR
In later versions of cvBlob, openCV is automatically located. But version 0.10.4 and before expects the openCV directory to be located next to the cvblob directory. Specifically, version 0.10.4 seems to expect the opencv-2.4.9 directory to be next to cvblob. In this version of cvBlob, the -DOpenCV_DIR parameter seems to have no effect on OS X, and this was the only way I could get it working.
Are you working with Xcode?
If so, just add the OpenCV-path to your header search path in your Xcode project.

How to setup Qt Creator to work with CMake on Mac with Qt 4.7 SDK?

I'm using Qt Creator 2.2.1 under MacOS X 10.6.8, standard MacOS X install for CMake 2.8.5 and Qt SDK version 1.1.2 released on June 21st (Qt 4.7.3 libraries).
My CMakeLists.txt fails in the find_package for Qt4 -- the second of the lines below:
set (CMAKE_MODULE_PATH /Applications/CMake 2.8-5.app/Contents/share/cmake-2.8/Modules)
find_package (Qt4 REQUIRED HINTS /Users/myname/QtSDK)
I added the first just to make sure it knew where FindQt4.cmake lives, but same error either with or without that line.
The error from CMake is as follows:
-- Configuring incomplete, errors occurred!
CMake Error at CMakeLists.txt:30 (find_package):
Could not find a configuration file for package Qt4.
Set Qt4_DIR to the directory containing a CMake configuration file for Qt4.
The file will have one of the following names:
Qt4Config.cmake
qt4-config.cmake
I've done some finds in both the installed QtSDK location and the CMake directories, and there's no Qt4Config.cmake. I did see in the CMake module directory -- FindQt4.cmake, Qt4ConfigDependentSettings.cmake, and UseQt4.cmake
According to this page:
The find_package() command will look in the module path for Find.cmake,
which is the typical way for finding libraries. First CMake checks all directories in
${CMAKE_MODULE_PATH}, then it looks in its own module directory
/share/cmake-x.y/Modules/.
If no such file is found, it looks for Config.cmake or
-config.cmake, which are supposed to be installed by libraries
(but there are currently not yet many libraries which install them) and
that don't do detection, but rather just contain hardcoded values for the
installed library.
So it seems like FindQt4.cmake should find the Qt4 I'm hinting at its location -- so why is it even making it down to Qt4Config.cmake? Anyone get this to work on Mac with those standard installs?
The "find_package(Qt4..." command is very dependent on finding a qmake executable. Is "qmake" on your path? Try something like
set(QT_QMAKE_EXECUTABLE "<actual location of qmake on your system>")
find_package(Qt4 REQUIRED)
Edit: I meant to type QT_QMAKE_EXECUTABLE; and I did not grok your statement about CMAKE_MODULE_PATH at first.

Resources