Sysprogs forums › Forums › VisualGDB › Linking to new shared libraries during cross-compiling
- This topic has 2 replies, 2 voices, and was last updated 8 years, 6 months ago by William Knox.
-
AuthorPosts
-
May 10, 2016 at 10:54 #8194William KnoxParticipant
To whom it may concern,
I am having issues referencing new libraries in a Linux CMake cross-compilation project for the Raspberry Pi(rpi).
Image 1 below shows the current Target, Configuration-specific and Common settings for the CMake project settings.
Image 2 below shows the error received after the tool-chain consistency runs (after changing any settings in the CMake project settings page).
Despite the ${OpenCV_LIBS} and raspicam_cv and raspicam no such file or directory errors I have been able to successfully build the project with those errors. I do not know if they are referring to include or library errors.
I recently installed FFMpeg on the target and performed a sysroot update. This copied a number of include files to /usr/local/include and library files to /usr/local/lib as shown in figures 3 and 4 respectively.
Visual Studio is giving ‘undefined reference to’ errors. They are functions that are in the libavformat, libavcodec, libavutil and libswscale libraries. I have successfully built a program using this libraries with the following simple command-line command (on rpi): gcc -o tutorial01 tutorial01.c -lavformat -lavcodec -lavutil -lswscal
Figures 5 and 6 are excerpts from the VS build output.
A copy of the current CMakeLists.txt file is presented at the bottom of this post.
I don’t believe I have enough of an understanding of how the VisualGDB projects settings effect the cross-compilation build process. I have successfully built the OpenCV 3.1 and Raspicam cross-compile project tutorials.
I am using Visual Studio 2013 (Ultimate Edition) with VisualGDB Custom Edition version 5.0.
I am performing a Linux Application type project. I am cross-compiling to the Raspberry Pi2 with Jessie-lite.
Any help in understanding the nature of the error would be greatly appreciated.
Cmake Project Settings Page” width=”1344″ height=”756″ /> Fig1: Project Settings->Cmake Project Settings Page
[caption id="" align="alignnone" width="1424"] Fig2: Tool-chain check errors[/caption]
[caption id="" align="alignnone" width="688"] Fig3: …/sysroot/usr/local/include folder contents[/caption]
[caption id="" align="alignnone" width="609"] Fig4: …/sysroot/usr/local/lib folder contents[/caption]
[caption id="" align="alignnone" width="2022"] Fig5: VS Build log excerpt 1[/caption]
CMakeLists.txt
—————————————————————————————————————————————————————————————————–
#Generated by VisualGDB project wizard.
#Note: VisualGDB will automatically update this file when you add new sources to the project.cmake_minimum_required(VERSION 2.7)
project(FDBA_singular_ert)
set(LIBRARIES_FROM_REFERENCES “”)
add_executable(FDBA_singular_ert abs.cpp abs1.cpp applyScalarFunctionInPlace.cpp assertValidSizeArg.cpp BlobAnalysis.cpp bsxfun.cpp CameraParametersImpl.cpp ceil.cpp ceil1.cpp colon.cpp combine_vector_elements.cpp detectForeground.cpp distortPoints.cpp div.cpp eml_int_forloop_overflow_check.cpp error.cpp FDBA_singular_ert.cpp fdba_singular_ert_data.cpp fdba_singular_ert_emxutil.cpp fdba_singular_ert_initialize.cpp fdba_singular_ert_rtwutil.cpp fdba_singular_ert_terminate.cpp floor.cpp floor1.cpp ForegroundDetector.cpp ImageTransformer.cpp imdilate.cpp imerode.cpp imopen.cpp indexIntRelop.cpp interp2.cpp isequal.cpp isfinite.cpp isinf.cpp isnan.cpp main.cpp meshgrid.cpp minOrMax.cpp morphop.cpp morphop1.cpp morphopAlgo.cpp NeighborhoodProcessor.cpp Nondirect.cpp power.cpp pvParse.cpp rdivide.cpp rem.cpp rem1.cpp repmat.cpp rtGetInf.cpp rtGetNaN.cpp rt_nonfinite.cpp scalexpAlloc.cpp setup.cpp sqrt.cpp sqrt1.cpp stereoParams.cpp stereoParams_CameraParameters1_ReprojectionErrors.cpp stereoParams_CameraParameters1_RotationVectors.cpp stereoParams_CameraParameters1_TranslationVectors.cpp stereoParams_CameraParameters1_WorldPoints.cpp stereoParams_CameraParameters2_ReprojectionErrors.cpp stereoParams_CameraParameters2_RotationVectors.cpp stereoParams_CameraParameters2_TranslationVectors.cpp stereoParams_CameraParameters2_WorldPoints.cpp strcmp.cpp sum.cpp System.cpp SystemCore.cpp SystemProp.cpp undistortImage.cpp validateattributes.cpp)
#target_link_libraries(FDBA_singular_ert “${LIBRARIES_FROM_REFERENCES}”)find_package(OpenCV REQUIRED)
ocv_include_directories(“${OpenCV_SOURCE_DIR}/include”)
ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
target_link_libraries(FDBA_singular_ert ${OpenCV_LIBS} raspicam_cv raspicam avformat avcodec avutil swscale “${LIBRARIES_FROM_REFERENCES}”)
include_directories(E:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot/usr/local/include ../raspicam-0.1.3/src C:/opencv-3.1.0/build/Debug/install)
#NOTE: For some unknown reason the user variable ${RASPICAM_DIR} was not accepted by cmake whereas the ../ and /../ path references were.
#NOTE: The VisualGDB intellisense settings did not like the ../ format to the OpenCV include path C:/opencv-3.1.0/build/Debug/install/include
#NOTE: Perform a project clean deletes the [non-default] inteliisense directories#NOTE: Two custom debug steps must be added to upload libraspicam.so.1 and libraspicam_cv.so to the RAPI2 /home/pi/builds directory; since this directory is outside the normal Linux library directories
# the /home/pi/builds path must be added to the LD_LIBRARY_PATH variable.#NOTE: Somehow an extra / was added to the Deploy main executable to variable, /home/pi/builds/$(TargetFileName)
set(CMAKE_C_FLAGS “${CMAKE_C_FLAGS} “)
set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -fopenmp -pthread -std=c++11”)
set(MY_GCC_COVERAGE_LINK_FLAGS “-fopenmp -pthread”)
set(CMAKE_EXE_LINKER_FLAGS “${MY_GCC_COVERAGE_LINK_FLAGS}”)set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} )
—————————————————————————————————————————————————————————————————–
Wil
- This topic was modified 8 years, 6 months ago by William Knox.
- This topic was modified 8 years, 6 months ago by William Knox.
May 11, 2016 at 05:48 #8201supportKeymasterHi,
This is actually a limitation of the algorithm used by VisualGDB to detect compiler/linker settings from the project settings. It does not work for projects with variables like ${OpenCV_LIBS}.
However it should not affect building or IntelliSense as long as you have the ‘configure IntelliSense based on CFLAGS’ flag set, so you can simply press the ‘ignore’ button when VisualGDB reports this.
May 12, 2016 at 03:42 #8212William KnoxParticipantThank you for your assistance.
Sysprogs support also mentioned that I must enclose the FFMpeg-based header declarations in an extern “C” block, since the code that refers to those functions expect them to be declared with C++ names; after doing this there were no more ‘undefined referenced to’…linker errors.
Wil
-
AuthorPosts
- You must be logged in to reply to this topic.