I am compiling linux kernel version 3.17. by default a driver is statically compiled into the linux kernel and is probed at boot time. But I want this particular driver to be build as a module so I changed the CONFIG_driver from 'y' to 'm'. But after doing so the kernel outputs an undefined reference error and breaks the build.
following console log
| LD drivers/built-in.o
| LINK vmlinux
| LD vmlinux.o
| MODPOST vmlinux.o
| GEN .version
| CHK include/generated/compile.h
| UPD include/generated/compile.h
| CC init/version.o
| LD init/built-in.o
| drivers/built-in.o: In function `adv7511_irq_handler':
| /var/adnan/work/git/mel_repos/mel_cedar_2/build/build_zedboard-zynq7-mel/tmp/work-shared/zedboard-zynq7-mel/kernel-source/drivers/gpu/drm/i2c/adv7511_core.c:314: undefined reference to `drm_helper_hpd_irq_event'
| make: *** [vmlinux] Error 1
| ERROR: oe_runmake failed
where as the function drm_helper_hpd_irq_event is present in drm_probe_helper.c. and according to the makefile
obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
the module which I am building selects CONFIG_DRM_KMS_HELPER. In the .config this is directly proportional to my module when I build my module this also gets build in module and otherwise it build statically. But when it builds in module the file is not compiled.
Any Idea ? How can I force this into static build while doing my driver in module ?
As a workaround, you can replace
obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o
by
obj-y += drm_kms_helper.o
Related
I am having difficulty importing a python extension module that depends on a separate shared library that I am building via a separate build system. When I attempt to import the module, I get an undefined symbol error:
import ext_mod
ImportError: /ext_mod_path/ext_mod.so: undefined symbol: __mangled_func_name
This makes a certain amount of sense, since it's missing from the extension module shared library, as it's contained in the separate shared library.
$ nm /ext_mod_path/ext_mod.so | grep __mangled_func_name
U __mangled_func_name
But the extension module library can successfully find the shared common library:
$ ldd /ext_mod_path/ext_mod.so
libmodcommon.so => /user_lib_path/libmodcommon.so (0x...)
And the symbol is defined there
$ nm /user_lib_path/libmodcommon.so | grep __mangled_func_name
000000000002e750 T __mangled_func_name
Why can't the symbol be seen in ext_mod.so?
For reference, the linker command for the extension module is:
g++ -o ext_mod.so -shared -Wl,-rpath=/user_lib_path ext_mod.os -L/user_lib_path -lmodcommon
I generated toolchain with Yocto for qemuarm, by running the following command: 'bitbake -c populate_sdk core-image-minimal' and installed on my build machine, Following are the commands i am executing for busybox to compile.
. /opt/poky/3.1.14/environment-setup-armv7vet2hf-neon-poky-linux-gnueabi
wget https://busybox.net/downloads/busybox-1.30.0.tar.bz2
tar xvf busybox-1.30.0.tar.bz2
make ARCH=arm CROSS_COMPILE=arm-poky-linux-gnueabi-gcc defconfig
make ARCH=arm CROSS_COMPILE=arm-poky-linux-gnueabi- defconfig
make ARCH=arm CROSS_COMPILE=arm-poky-linux-gnueabi- menuconfig
make ARCH=arm CROSS_COMPILE=arm-poky-linux-gnueabi- install
The compilation is failing with the below error:
CC applets/applets.o
In file included from /opt/poky/3.1.14/sysroots/x86_64-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.3.0/include-fixed/syslimits.h:7,
from /opt/poky/3.1.14/sysroots/x86_64-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.3.0/include-fixed/limits.h:34,
from include/platform.h:153,
from include/libbb.h:13,
from include/busybox.h:8,
from applets/applets.c:9:
/opt/poky/3.1.14/sysroots/x86_64-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.3.0/include-fixed/limits.h:194:61: error: no include path in which to search for limits.h
194 | #include_next <limits.h> /* recurse down to the real one */
| ^
In file included from include/libbb.h:13,
from include/busybox.h:8,
from applets/applets.c:9:
include/platform.h:164:11: fatal error: byteswap.h: No such file or directory
164 | # include <byteswap.h>
| ^~~~~~~~~~~~
compilation terminated.
make[1]: *** [scripts/Makefile.build:198: applets/applets.o] Error 1
make: *** [Makefile:372: applets_dir] Error 2
Can you please help me on this
I followed the guide in the page linphone-sdk and also run these with the MSYS2 MSYS command in Windows 10:
pacman -S mingw-w64-i686-cmake
pacman -S mingw-w64-i686-ninja
pacman -S p7zip
My PATH variable contains these:
...C:\msys64;C:\msys64\usr\bin;C:\msys64\mingw32\bin;C:\msys64\mingw64\bin;C:\msys64\usr\lib\p7zip;...
Then I run the configuration command:
cmake -DENABLE_AAUDIO=OFF -DENABLE_ADVANCED_IM=NO -DENABLE_AMRNB=OFF -DENABLE_AMRWB=OFF -DENABLE_ASSETS=NO -DENABLE_BV16=NO -DENABLE_CAMERA2=OFF -DENABLE_CODEC2=OFF -DENABLE_CSHARP_WRAPPER=OFF -DENABLE_CXX_WRAPPER=NO -DENABLE_DB_STORAGE=NO -DENABLE_DEBUG_LOGS=YES -DENABLE_DOC=OFF -DENABLE_EMBEDDED_OPENH264=OFF -DENABLE_FFMPEG=OFF -DENABLE_G726=OFF -DENABLE_G729=OFF -DENABLE_G729B_CNG=OFF -DENABLE_GPL_THIRD_PARTIES=NO -DENABLE_GSM=NO -DENABLE_GTK_UI=OFF -DENABLE_H263=OFF -DENABLE_H263P=OFF -DENABLE_ILBC=OFF -DENABLE_ISAC=OFF -DENABLE_JAVA_WRAPPER=OFF -DENABLE_JAZZY_DOC=OFF -DENABLE_JPEG=NO -DENABLE_LIME=OFF -DENABLE_LIME_X3DH=NO -DENABLE_MBEDTLS=YES -DENABLE_MDNS=OFF -DENABLE_MKV=NO -DENABLE_MPEG4=OFF -DENABLE_NLS=OFF -DENABLE_NON_FREE_CODECS=OFF -DENABLE_OPENH264=OFF -DENABLE_OPUS=NO -DENABLE_PCAP=OFF -DENABLE_POLARSSL=OFF -DENABLE_QRCODE=OFF -DENABLE_RTP_MAP_ALWAYS_IN_SDP=OFF -DENABLE_SILK=OFF -DENABLE_SOCI_MYSQL=OFF -DENABLE_SPEEX=YES -DENABLE_SQLITE=YES -DENABLE_SRTP=NO -DENABLE_SWIFT_WRAPPER=OFF -DENABLE_TOOLS=NO -DENABLE_TUNNEL=OFF -DENABLE_UNIT_TESTS=NO -DENABLE_UNMAINTAINED=OFF -DENABLE_UPDATE_CHECK=OFF -DENABLE_V4L=OFF -DENABLE_VCARD=NO -DENABLE_VIDEO=NO -DENABLE_VPX=OFF -DENABLE_WASAPI=ON -DENABLE_WEBRTC_AEC=YES -DENABLE_WEBRTC_AECM=YES -DENABLE_WEBRTC_VAD=OFF -DENABLE_X264=OFF -DENABLE_XML2=NO -DENABLE_ZLIB=NO -DENABLE_ZRTP=NO -DENABLE_ZRTP=OFF ..
and then the build command:
cmake --build .
I got following build errors (contains from the build log the parts where are the word "failed"):
...
[6/10] Forcing build for 'desktop'
[7/10] Performing build step for 'sdk'
FAILED: sdk-prefix/src/sdk-stamp/sdk-build C:/e/linphone-sdk/build/sdk-prefix/src/sdk-stamp/sdk-build
cmd.exe /C "cd /D C:\e\linphone-sdk\build\desktop && C:\msys64\mingw32\bin\cmake.exe --build . && C:\msys64\mingw32\bin\cmake.exe -E touch C:/e/linphone-sdk/build/sdk-prefix/src/sdk-stamp/sdk-build"
[1/128] Creating directories for 'EP_speex'
[2/128] Creating directories for 'EP_jsoncpp'
...
[29/128] Forcing build for 'EP_jsoncpp'
[30/128] Performing build step for 'EP_mbedtls'
FAILED: C:/e/linphone-sdk/build/WORK/desktop/Stamp/EP_mbedtls/EP_mbedtls-build
cmd.exe /C "cd /D C:\e\linphone-sdk\build\WORK\desktop\Build\mbedtls && C:\msys64\mingw32\bin\cmake.exe --build . && C:\msys64\mingw32\bin\cmake.exe -E touch C:/e/linphone-sdk/build/WORK/desktop//Stamp/EP_mbedtls/EP_mbedtls-build"
[1/89] Building C object library/CMakeFiles/mbedx509.dir/pkcs11.c.obj
[2/89] Building C object library/CMakeFiles/mbedx509.dir/certs.c.obj
...
[63/89] Building C object library/CMakeFiles/mbedcrypto.dir/pkcs5.c.obj
[64/89] Building C object library/CMakeFiles/mbedcrypto.dir/entropy_poll.c.obj
FAILED: library/CMakeFiles/mbedcrypto.dir/entropy_poll.c.obj
C:\msys64\mingw32\bin\cc.exe -Dmbedcrypto_EXPORTS -IC:/e/linphone-sdk/external/mbedtls/include -IC:/e/linphone-sdk/external/mbedtls/library -Wall -Wextra -Wwrite-strings -Wvla -Wlogical-op -Wshadow -Wformat-signedness -Werror -Wmissing-declarations -Wmissing-prototypes -O2 -g -DNDEBUG -D_WIN32_WINNT=0x0600 -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -w -MD -MT library/CMakeFiles/mbedcrypto.dir/entropy_poll.c.obj -MF library\CMakeFiles\mbedcrypto.dir\entropy_poll.c.obj.d -o library/CMakeFiles/mbedcrypto.dir/entropy_poll.c.obj -c C:/e/linphone-sdk/external/mbedtls/library/entropy_poll.c
C:/e/linphone-sdk/external/mbedtls/library/entropy_poll.c:59:101: error: missing binary operator before token "("
59 | #if defined(WINAPI_FAMILY_PARTITION) && defined (WINAPI_PARTITION_PC_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PC_APP)
| ^
[65/89] Building C object library/CMakeFiles/mbedcrypto.dir/version.c.obj
[66/89] Building C object library/CMakeFiles/mbedcrypto.dir/threading.c.obj
[67/89] Building C object library/CMakeFiles/mbedcrypto.dir/ecp.c.obj
[68/89] Building C object library/CMakeFiles/mbedcrypto.dir/platform.c.obj
[69/89] Building C object library/CMakeFiles/mbedcrypto.dir/sha256.c.obj
[70/89] Building C object library/CMakeFiles/mbedcrypto.dir/pkwrite.c.obj
[71/89] Building C object library/CMakeFiles/mbedcrypto.dir/sha512.c.obj
[72/89] Building C object library/CMakeFiles/mbedcrypto.dir/sha1.c.obj
[73/89] Building C object library/CMakeFiles/mbedcrypto.dir/poly1305.c.obj
[74/89] Building C object library/CMakeFiles/mbedcrypto.dir/pkparse.c.obj
[75/89] Building C object library/CMakeFiles/mbedcrypto.dir/rsa.c.obj
[76/89] Building C object library/CMakeFiles/mbedcrypto.dir/timing.c.obj
[77/89] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto.c.obj
ninja: build stopped: subcommand failed.
[31/128] Performing install step for 'EP_openldap'
[32/128] Performing configure step for 'EP_speex'
...
-- Performing Test VAR_ARRAYS - Success
-- Performing Test HAS_ALLOCA
-- Performing Test HAS_ALLOCA - Success
-- Performing Test HAS_SSE
-- Performing Test HAS_SSE - Failed
-- Performing Test HAS_VISIBILITY
-- Performing Test HAS_VISIBILITY - Success
...
C:/e/linphone-sdk/external/jsoncpp/src/lib_json/json_reader.cpp:756:34: warning: 'Reader' is deprecated: Use CharReader and CharReaderBuilder instead. [-Wdeprecated-declarations]
756 | Reader::Char Reader::getNextChar() {
| ^
In file included from C:/e/linphone-sdk/external/jsoncpp/src/lib_json/json_reader.cpp:10:
C:/e/linphone-sdk/external/jsoncpp/include/json/reader.h:37:63: note: declared here
37 | "Use CharReader and CharReaderBuilder instead.") JSON_API Reader {
| ^~~~~~
C:/e/linphone-sdk/external/jsoncpp/src/lib_json/json_reader.cpp:810:21: warning: 'Reader' is deprecated: Use CharReader and CharReaderBuilder instead. [-Wdeprecated-declarations]
810 | std::vector<Reader::StructuredError> Reader::getStructuredErrors() const {
| ^~~~~~~~~~~~~~~
In file included from C:/e/linphone-sdk/external/jsoncpp/src/lib_json/json_reader.cpp:10:
C:/e/linphone-sdk/external/jsoncpp/include/json/reader.h:37:63: note: declared here
37 | "Use CharReader and CharReaderBuilder instead.") JSON_API Reader {
| ^~~~~~
[10/11] Linking CXX static library lib\libjsoncpp.a
[11/11] Linking CXX shared library bin\libjsoncpp.dll
[34/128] Performing build step for 'EP_sqlite3'
[1/2] Building C object CMakeFiles/sqlite3.dir/sqlite3.c.obj
[2/2] Linking C shared library libsqlite3.dll
ninja: build stopped: subcommand failed.
ninja: build stopped: subcommand failed.
It seems that the real error is this:
I'm not sure what is the cause of the error message:
error: missing binary operator before token "("
Here What does the compiler error "missing binary operator before token" mean? is some definition about the error, but I'm not sure why the error happens. Does it happen only in the specific environment??
When I configured my environment according to the https://gitlab.linphone.org/BC/public/linphone-sdk/ page and used the Developer Command Prompt for VS 2017 the build seems to go through.
I have the following structure of projects/source:
MyProject
|-MyProject
| |-src
| | |-project.c
| |
| |-CMakeLists.txt
|
|-MyLibrary
|-include
| |-hello.h
|
|-src
| |-hello.c
|
|-CMakeLists.txt
MyProject/src/project.c includes MyLibrary/include/hello.h, which in turn includes libusb.h from the system (found using CMake).
And I am adding the libusb dependency in MyLibrary/CMakeLists.txt using the following code:
# Find libusb
find_package(LibUsb REQUIRED)
# Include libusb
include_directories(${LIBUSB_INCLUDE_DIR})
# Add dependencies
target_link_libraries(owi535 ${LIBUSB_LIBRARY})
However when compiling MyProject (which includes MyLibrary using add_subdirectory and target_link_libraries), I get an error stating libusb.h cannot be found.
I can compile MyLibrary on it's own, however compiling MyProject requires libusb.h to be in it's include path, which it is not.
Is there a way to make it so that by adding MyLibrary as a dependency, MyProject pulls libusb.h through it? This would mean that I don't need to repeat the find_package code for every project that includes MyLibrary.
The other issue I am having is similar; I am getting an error stating that there are Undefined symbols when calling libusb functions in MyLibrary when I compile MyProject, however when compiling MyLibrary on it's own, there are no errors.
Undefined symbols for architecture x86_64:
"_libusb_close", referenced from:
_my_close_method in libMyLibrary.a(hello.c.o)
"_libusb_exit", referenced from:
_my_exit_method in libMyLibrary.a(hello.c.o)
"_libusb_init", referenced from:
_my_init_method in libMyLibrary.a(hello.c.o)
"_libusb_open_device_with_vid_pid", referenced from:
_my_open_method in libMyLibrary.a(hello.c.o)
ld: symbol(s) not found for architecture x86_64
From the cmake documentation:
PUBLIC and INTERFACE items will populate the INTERFACE_INCLUDE_DIRECTORIES property of <target>.
Targets may populate this property [INTERFACE_INCLUDE_DIRECTORIES] to publish the include directories required to compile against the headers for the target. Consuming targets can add entries to their own INCLUDE_DIRECTORIES property such as $<TARGET_PROPERTY:foo,INTERFACE_INCLUDE_DIRECTORIES> to use the include directories specified in the interface of foo.
So, you need to use this in MyLibrary/CMakeLists.txt:
target_include_directories(MyLibrary PUBLIC ${LIBUSB_INCLUDE_DIR})
I'm doing a project in which I need to connect to an AR.Drone 2.0. I have a functional GUI in Java, but to control the drone I have to use it's SDK which is a C library. I wrote the necessary functions to combine Java and C via JNI, but because of the modifications I did to an example delivered with the SDK, it doesn't build anymore. It is thought to be built with a makefile (which I also have tried changing without success) running the make command. The problem is I am very new to C and makefiles, and I have searched the web a lot but have not found any solution. So here's how the library looks like:
.: Folder root
|
+ src: Sources
|
+ ARDroneLib: The AR.Drone Library
| |
| + Soft: Containing the "interesting" part of the whole lib
| | |
| | + More subdirs... (Build: contains a makefile, Common: c and h files, Lib: stuff)
| |
| + Many other subdirectories (FFMPEG, ITTIAM, VLIB, VP_SDK)
|
+ DroneControl: My own code
|
+ Source:The source files
| |
| + Navdata: Code to retrieve the navigation data
| | |
| | + navdata.c
| | + navdata.h
| |
| + Video: Code to retrieve the drone's video stream
| | |
| | + video_stage.c
| | + video_stage.h
| |
| + ardrone_testing_tool.c: Main file, containing the main function, etc.
| + ardrone_testing_tool.h: Its header
| + dronecontrol_ARDrone: My own file, containing JNI methods (also has an init() function which calls main() in ardrone_testing_tool.c)
| + dronecontrol_ARDrone: Its header
| + vars.h: Some shared variables
|
+ Build:Contains the makefile
|
+ makefile: The makefile
Here's the makefile in ./src/DroneControl/Build/:
SDK_PATH:=$(shell pwd)/../../ARDroneLib
PC_TARGET=yes
USE_LINUX=yes
ifdef MYKONOS
include $(ARDRONE_CUSTOM_CONFIG)
include $(ARDRONE_BUILD_CONFIG)
else
include $(SDK_PATH)/Soft/Build/custom.makefile
include $(SDK_PATH)/Soft/Build/config.makefile
endif
ifeq "$(RELEASE_BUILD)" "yes"
ARDRONE_TARGET_DIR=$(shell pwd)/../../../
else
ARDRONE_TARGET_DIR=$(shell pwd)/../../../Debug
endif
TARGET=linux_sdk_demo
SRC_DIR:=$(shell pwd)/../Sources
# Define application source files
GENERIC_BINARIES_SOURCE_DIR:=$(SRC_DIR)
GENERIC_BINARIES_COMMON_SOURCE_FILES+= \
Navdata/navdata.c \
Video/video_stage.c
GENERIC_INCLUDES+= \
$(SRC_DIR) \
$(LIB_DIR) \
$(SDK_PATH)/Soft/Common \
$(SDK_PATH)/Soft/Lib
GENERIC_TARGET_BINARIES_PREFIX=
GENERIC_TARGET_BINARIES_DIR=$(ARDRONE_TARGET_DIR)
GENERIC_BINARIES_SOURCE_ENTRYPOINTS+= \
ardrone_testing_tool.c
GENERIC_INCLUDES:=$(addprefix -I,$(GENERIC_INCLUDES))
GENERIC_LIB_PATHS=-L$(GENERIC_TARGET_BINARIES_DIR)
GENERIC_LIBS=-lpc_ardrone -lgtk-x11-2.0 -lrt
SDK_FLAGS+="USE_APP=yes"
SDK_FLAGS+="APP_ID=linux_sdk_demo"
export GENERIC_CFLAGS
export GENERIC_LIBS
export GENERIC_LIB_PATHS
export GENERIC_INCLUDES
export GENERIC_BINARIES_SOURCE_DIR
export GENERIC_BINARIES_COMMON_SOURCE_FILES
export GENERIC_TARGET_BINARIES_PREFIX
export GENERIC_TARGET_BINARIES_DIR
export GENERIC_BINARIES_SOURCE_ENTRYPOINTS
export GENERIC_LIBRARY_SOURCE_DIR=$(GENERIC_BINARIES_SOURCE_DIR)
.PHONY: $(TARGET) build_libs
all: build_libs $(TARGET)
$(TARGET):
#$(MAKE) -C $(SDK_PATH)/VP_SDK/Build $(TMP_SDK_FLAGS) $(SDK_FLAGS) $(MAKECMDGOALS) USE_LINUX=yes
mv $(ARDRONE_TARGET_DIR)/ardrone_testing_tool $(TARGET)
mv $(TARGET) $(ARDRONE_TARGET_DIR)/
$(MAKECMDGOALS): build_libs
#$(MAKE) -C $(SDK_PATH)/VP_SDK/Build $(TMP_SDK_FLAGS) $(SDK_FLAGS) $(MAKECMDGOALS) USE_LINUX=yes
build_libs:
#$(MAKE) -C $(SDK_PATH)/Soft/Build $(TMP_SDK_FLAGS) $(SDK_FLAGS) $(MAKECMDGOALS) USE_LINUX=yes
But when I try to make this, the make command gives me following error:
Libs already extracted
Building target static
/bin/sh: 1: ./autoConf.bash: Permission denied
make[2]: *** [build] Error 126
Checking required Ubuntu packages ...
ok.
Building ARDroneTool/Lib
Building ARDroneTool/Lib
ld ardrone_testing_tool
/usr/bin/ld: cannot find -lswscale
/usr/bin/ld: cannot find -lavformat
/usr/bin/ld: cannot find -lavcodec
/usr/bin/ld: cannot find -lavutil
collect2: ld returned 1 exit status
make[3]: *** [/home/user/workspace/AutoFlight/lib/native/DroneControl/src/DroneControl/Build/../../..//ardrone_testing_tool] Error 1
make[2]: *** [all] Error 2
make[1]: *** [build_app] Error 2
make: *** [linux_sdk_demo] Error 2
I have not been able to figure out what -lwscale, -lavformat, etc. are. I have also tried the make command as su (mainly because that "Permission denied" error), and hope this is the right place to ask this.
So does anybody have suggestions on how to get this compiled into a dynamically linked library (.so file)? Any help would be highly appreciated!
UPDATE 1: The permission denied error is now solved (thanks #eyalm)
UPDATE 2: It works now. I've rewritten the makefile but I don't know what's different now that could affect ld's path.
autoConf.bash is probably not executable. Running with su will not help. try:
# chmod a+x autoConf.bash
> /usr/bin/ld: cannot find -lswscale
> /usr/bin/ld: cannot find -lavformat
> /usr/bin/ld: cannot find -lavcodec
> /usr/bin/ld: cannot find -lavutil
> collect2: ld returned 1 exit status
It could be that these dependencies (i.e., libswscale, libavformat, libavcodec,
and libavutil) are either not present on your system, or are present
in directories that are not part of ld's standard search path.
If the dependencies are absent, then you would need to install them. On Debian-derived systems you could use the apt-file command to find the package you would need to install. For example:
% apt-file -l find libswscale.a
libswscale-dev
% apt-file -l find libavutil.a
libavutil-dev
...etc...
If these libraries are already present on your system, but are in non-standard locations,
you could use ld's -L option to add the relevant directories to its search path. For example:
% ld ..other-options... -L SEARCHDIR1 -L SEARCHDIR2 ... -lswscale -lavutil ...etc...
Note that the -L SEARCHDIR options need to appear before the -l
LIB options.