I want to use static library(libglog.a) not shared with my heartbeat app.
The glog lib(https://github.com/google/glog) I used is depends on unwind lib refer by this link Why a static library can depend on a shared a library?
I also encountered this problem too ! #Ke Yang
But I am new to CMake, I don' know how to link unwind.so please?
Here is my CMakeLists.txt
include_directories(
${CMAKE_CURRENT_LIST_DIR}
)
link_directories(
)
add_executable( heartbeat
main.cpp
heartbeat.cpp
${COMPONENTS_SRC}
${MODULES_SRC}
)
target_link_libraries( heartbeat
libpthread.a
libcrypt.a
libm.a
libgflags.a
libglog.a
libhiredis.a
libredis++.a
)
# 输出到build文件夹上层目录
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/..)
Then I get this ERROR
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libglog.a(libglog_la-utilities.o):在函数‘google::GetStackTrace(void**, int, int) [clone .part.7]’中:
(.text+0xad):对‘_Ux86_64_getcontext’未定义的引用
(.text+0xb8):对‘_ULx86_64_init_local’未定义的引用
(.text+0xe7):对‘_ULx86_64_step’未定义的引用
(.text+0x100):对‘_ULx86_64_get_reg’未定义的引用
(.text+0x120):对‘_ULx86_64_step’未定义的引用
collect2: error: ld returned 1 exit status
Related
I'm trying to use the VoxelGrid of the pcl library to filter my PointCloud, extracted from a ros message. So the following is the part of code related to this problem:
pcl::PCLBase<pcl::PCLPointCloud2>::PCLPointCloud2ConstPtr cloudPtr(cloud_pc2);
pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
sor.setInputCloud(cloudPtr);
sor.setLeafSize(0.1f, 0.1f, 0.1f);
sor.filter(cloud_filtered);
I saw online tutorials where they directly do:
pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2 ());
pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
sor.setInputCloud (cloud);
sor.setLeafSize (0.01f, 0.01f, 0.01f);
sor.filter (*cloud_filtered);
But in both cases I got undefined reference for the setInputCloud function. Have someone an idea of why this happens? I will attach also my CmakeList file
cmake_minimum_required(VERSION 3.5)
project(loam_os2)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
#set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(PCL 1.10 REQUIRED)
find_package(pcl_conversions REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS} include)
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcl_example_node src/pcl_example.cpp src/pcl_example_node.cpp)
target_link_libraries( pcl_example_node
${PCL_LIBRARIES}
)
ament_target_dependencies(
pcl_example_node
rclcpp
std_msgs
sensor_msgs
pcl_conversions
tf2
tf2_ros
)
install(TARGETS
pcl_example_node
DESTINATION lib/${PROJECT_NAME})
# Install launch files.
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()
Thank you in advance for any suggestion
here the full error:
usr/bin/ld: CMakeFiles/pcl_example_node.dir/src/pcl_example.cpp.o: in function Pcl_example::lidar_callback(std::shared_ptr<sensor_msgs::msg::PointCloud2_<std::allocator<void> > >)':
pcl_example.cpp:(.text+0x122f): undefined reference topcl::PCLBase<pcl::PCLPointCloud2>::setInputCloud(std::shared_ptr<pcl::PCLPointCloud2 const> const&)'
collect2: error: ld returned 1 exit status
make[2]: * [CMakeFiles/pcl_example_node.dir/build.make:360: pcl_example_node] Error 1
make[1]: * [CMakeFiles/Makefile2:78: CMakeFiles/pcl_example_node.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
Failed <<< loam_os2 [12.2s, exited with code 2]
Summary: 0 packages finished [12.5s]
1 package failed: loam_os2
1 package had stderr output: loam_os2
Starting with version 1.11.0, PCL uses std::shared_ptr instead of boost::shared_ptr. It seems you are using PCL 1.10, so setInputCloud would expect a boost::shared_ptr, however you are passing a std::shared_ptr. Since I can't see where cloudPtr or cloud respectively come from in your code snippets, I am unable to suggest a solution, except to use a newer PCL version.
I have a skia shared library generated from skia source code, i want use it to draw something in my cpp file. This project runs well on android M and N, but it crashed on android L.
This is my CMakeList.txt
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on)
set(libs "${CMAKE_SOURCE_DIR}/src/main/jniLibs")
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/android)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/atlastext)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/c)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/codec)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/config)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/core)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/effects)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/encode)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/gpu)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/pathops)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/ports)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/private)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/svg)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/utils)
include_directories(${CMAKE_SOURCE_DIR}/src/main/cpp/include/views)
#--------------------------------------------------- import ---------------------------------------------------#
add_library(libmyskia SHARED IMPORTED )
set_target_properties(libmyskia PROPERTIES
IMPORTED_LOCATION "${libs}/${ANDROID_ABI}/libmyskia.so")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -fexceptions -fno-rtti")
add_library(eskia
SHARED
src/main/cpp/eskia.cpp )
find_library( android-lib
android)
target_link_libraries(eskia
libmyskia
${android-lib}
)
I load the library in my activity:
static {
System.loadLibrary("myskia");
System.loadLibrary("eskia");
}
Here is the crash info, has anyone meet this?
04-02 16:46:55.319 21449-21449/com.eastedu.skiaandroid E/art: dlopen("/data/app/com.eastedu.skiaandroid-2/lib/arm/libeskia.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "_ZTVN10__cxxabiv117__class_type_infoE" referenced by "libeskia.so"...
04-02 16:46:55.319 21449-21449/com.eastedu.skiaandroid D/AndroidRuntime: Shutting down VM
04-02 16:46:55.319 21449-21449/com.eastedu.skiaandroid E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.eastedu.skiaandroid, PID: 21449
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZTVN10__cxxabiv117__class_type_infoE" referenced by "libeskia.so"...
at java.lang.Runtime.loadLibrary(Runtime.java:383)
at java.lang.System.loadLibrary(System.java:997)
at com.eastedu.skiaandroid.MainActivity.<clinit>(MainActivity.java:17)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1606)
at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2535)
at android.app.ActivityThread.access$1200(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1387)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5689)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at enter code herecom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
package: busybox
version: 1.23.2
when i make busybox , it produces unexpected results.
the crosschaintool i use is ARM/uClinux Toolchain arm-2010q1-189-arm- uclinuxeabi-i686-pc-linux-gnu,but i can't make the busybox,like this:
root#ubuntu:/busybox/busybox-1.23.2# make
SPLIT include/autoconf.h -> include/config/*
GEN include/bbconfigopts.h
HOSTCC applets/usage
applets/usage.c: In function ‘main’:
applets/usage.c:52:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(STDOUT_FILENO, usage_array[i].usage, strlen(usage_array[i].usage) + 1);
^
GEN include/usage_compressed.h
HOSTCC applets/applet_tables
applets/applet_tables.c: In function ‘main’:
applets/applet_tables.c:161:4: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
fgets(line_old, sizeof(line_old), fp);
^
GEN include/applet_tables.h
CC applets/applets.o
LD applets/built-in.o
HOSTCC applets/usage_pod
applets/usage_pod.c: In function ‘main’:
applets/usage_pod.c:74:3: warning: format not a string literal and no format arguments [-Wformat-security]
printf(usage_array[i].aname);
^
CC libbb/appletlib.o
CC libbb/vfork_daemon_rexec.o
AR libbb/lib.a
CC shell/hush.o
shell/hush.c: In function 'builtin_source':
shell/hush.c:8901: warning: 'sv.sv_g_malloced' may be used uninitialized in this function
shell/hush.c:8901: warning: 'sv.sv_g_argc' may be used uninitialized in this function
shell/hush.c:8901: warning: 'sv.sv_g_argv' may be used uninitialized in this function
shell/hush.c:8901: warning: 'sv.sv_argv0' may be used uninitialized in this function
AR shell/lib.a
LINK busybox_unstripped
Trying libraries: crypt m
Library crypt is not needed, excluding it
Library m is not needed, excluding it
Final link with: <none>
arm-uclinuxeabi-strip:busybox_unstripped: File format not recognized
Makefile:723: recipe for target 'busybox' failed
make: *** [busybox] Error 1
how should i do? is the busybox can't use the ARM/uClinux Toolchain? how should i do ?we'll really appreciate it if you can give us some advice and some pieces of guidance,thanks!
LINK busybox_unstripped Trying libraries: crypt m Library crypt
is not needed, excluding it Library m is not needed, excluding it
Final link with: arm-uclinuxeabi-strip:busybox_unstripped: File
format not recognized Makefile:723: recipe for target 'busybox' failed
make: *** [busybox] Error 1
As there is only a piece of the whole compiling log, some suggestions are:
1) Please check the compiling log from the beginning whether there are other important warnings or errors.
2) busybox_unstripped file is generated or not? Check the makefile dependencies to find out whether all dependencies files are successfully generated. From the log, some libraries are excluded so that you may have to check the busybox configuration file.
3) If busybox_unstripped file is generated, check the makefile about the link grammar of "Final link with:". For the cross-tool chain to link successfully, please make sure the link command is correct.
Good luck!
working on an embedded Linux i get a strange error.
conftest.c:37:10: warning: implicit declaration of function 'htobe32'
[-Wimplicit-function-declaration]
n_be = htobe32(n_uint32);<br>
/tmp/cckbgVe5.o: In function main:
conftest.c:(.text+0x18): undefined reference to `htobe32'
collect2: error: ld returned 1 exit status
I guess anything is proper installed, because i can find the endian-Headers. Although, i don't know which Library is actually needed.
/usr/share/man/man3/endian.3.gz
/usr/include/bits/endian.h
/usr/include/linux/byteorder/little_endian.h
/usr/include/linux/byteorder/big_endian.h
/usr/include/endian.h
This is my path:
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bi/vendor_perl:/usr/bin/core_perl
Is a lib missing?
I'm trying to install OpenCV-2.4.9 on CentOS 7 (PC) however getting error after 16% when running "make" command. I leave default configuration for OpenCV.
make
...
[ 16%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_v4l.cpp.o /opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:306:29: error: field ‘capability’ has incomplete type
struct video_capability capability;
^ /opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:307:29: error: field ‘captureWindow’ has incomplete type
struct video_window captureWindow;
....
....
/opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp: In function ‘void icvCloseCAM_V4L(CvCaptureCAM_V4L*)’:
/opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:2812:46: error: ‘CvCaptureCAM_V4L’ has no member named ‘memoryBuffer’
It seems that the define HAVE_CAMV4L has the value 1, if you look in the file modules/highgui/src/cap_v4l.cpp looking for the structure definition at the row 306. If the compilation fails at that point this means that the video4linux development configuration is corrupted.
Using google I have found that the OpenCV Bug #1357 is described as follow:
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L) succeeds even though linux/videodev.h doesn't exist on the system. (Bug #1357)
http://code.opencv.org/issues/1357
Anyway the solution is described at the same URL for "HAVE_CAMV4L gets set incorrectly": "Setting it to FALSE in CMakeLists.txt fixes the problem".