Trying to get a working directfb for use in an embedded system based on an i.MX53 processor (which is an ARM Cortex-A8 core) running Linux 2.6.35.3 (as supplied by Freescale).
I have installed a cross compiler on my i686 debian host system. The cross compiler came from the embedian.org archive, and is the gcc-4.3-arm-linux-gnueabi package (arm-linux-gnueabi-gcc (Debian 4.3.2-1.1) 4.3.2). This is supplied with glibc 2.7. This is a different version from the version on my target system, which is glibc 2.11, although my reading suggests that they should be compatible.
After much experimentation with the libraries already existing on the system image, I have managed to successfully compile directfb 1.6.2. This was complicated by the fact that I do not have working pkg-config info for the already-installed libraries, but I eventually managed to persuade it to compile using the following configure command line:
TOP=`realpath ../..`
PKG_CONFIG_PATH=${TOP}/ext/libpng-1.5.13/ \
LIBPNG_CFLAGS=-I${TOP}/include \
LIBPNG_LDFLAGS="-L${TOP}/libs -lpng15 -lz" \
FREETYPE_CFLAGS=-I${TOP}/include \
FREETYPE_LIBS="-L${TOP}/libs -lfreetype" \
LIBS="-lgcc_s -lgcc -ldl -lstdc++ -lz" \
CFLAGS="-march=armv7-a" \
CXXFLAGS="-march=armv7-a" \
./configure CC=arm-linux-gnueabi-gcc CPPFLAGS=-I${TOP}/include LDFLAGS=-L${TOP}/lib \
--build=i686-linux --host=arm-linux-gnueabi \
--enable-static --disable-shared \
--disable-freetype --enable-fbdev --disable-x11 \
--with-gfxdrivers=none --with-inputdrivers=none
This successfully builds, and I can compile and link a sample application based on the simple tutorial application at http://directfb.org/docs/DirectFB_Tutorials/simple.html -- unfortunately, when run on the target system, the application crashes with SIGSEGV. So too do some of the tools included with directfb, e.g. dfbinfo.
Here is a stack trace of my test application crashing (when run with command line arg "--dfb:fbdev=/dev/fb0"):
#0 direct_map_lookup (map=0x0, key=0xdfd70) at map.c:298
#1 0x000b2d9c in direct_config_set (name=0xdfd70 "fbdev",
value=0xdfd76 "/dev/fb0") at conf.c:542
#2 0x0009edc0 in dfb_config_set (name=0xdfd70 "fbdev",
value=0xdfd76 "/dev/fb0") at conf.c:2024
#3 0x000a2dcc in parse_args (args=0x7ea80d53 "fbdev=/dev/fb0") at conf.c:297
#4 0x000a305c in dfb_config_init (argc=0x7ea80968, argv=0x7ea80964)
at conf.c:2159
#5 0x0000cd58 in Display::Display ()
#6 0x0000ba94 in main ()
For reference, the only directfb-related code to execute in the application prior to the crash is directly copied from the tutorial code:
Display::Display(int argc, char ** argv)
{
DFBSurfaceDescription dsc;
DFBCHECK (DirectFBInit (&argc, &argv));
// ... crash occurs during execution of the line above
}
This is called directly from my main function, passing the original unmodified argc and argv.
I have installed the directfb libraries on the target system in /usr/local/lib and binaries in /usr/local/bin, and created /usr/local/share/directfb-1.6.2 (containing cursor.dat and decker.dgiff) as well as /etc/fb.modes as suggested in the documentation.
Any suggestions as to what I've done wrong?
Reading source codes for conf.c and maps.c from git.directfb.org and checking your stack...
#0 direct_map_lookup (map=0x0, key=0xdfd70) at map.c:298
#1 0x000b2d9c in direct_config_set (name=0xdfd70 "fbdev", value=0xdfd76 "/dev/fb0") at conf.c:542
map is null. Which should assert at map.c:295 but looks like that's disabled but instead crashes at 298
hash = map->hash( map, key, map->ctx );
Previous call is in conf.c:542,
ConfigOption *option = direct_map_lookup( config_options, name );
which means config_options was null. Searching in that file only place it gets assigned to a file is __D_conf_init().
I don't know anything about directfb, but it looks like you need to call __D_conf_init directly or indirectly.
Related
I inherited a C++ code with a dependency to OpenMPI that I want to delegate to Conan and CMake, and the automated build has a strange (to me at least) behavior related to sysctl that I want to understand.
How I tried to do it
I declared the required dependencies in my root CMakeLists.txt:
Note: I added the full list of requirements because I also suspect that some of them may be in conflict? That happened before with boost, that forced me to set explicitly zlib (if i remember correctly).
# stuff ...
conan_cmake_configure(
REQUIRES
zlib/1.2.12
mp-units/0.7.0
boost/1.79.0
openmpi/4.1.0
gsl/2.7
cspice/0067
GENERATORS
cmake
# that is required for cspice
CMakeDeps
CMakeToolchain
)
# more stuff ...
and then in the application CmakeLists.txt I find, include and link the executable to the required libraries:
add_executable(spock main.cpp)
find_package(cspice REQUIRED)
find_package(openmpi REQUIRED)
target_include_directories(
spock PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
openmpi_INCLUDE_DIRS
cspice_INCLUDE_DIRS
)
target_link_libraries(spock
CONAN_PKG::boost
CONAN_PKG::mp-units
openmpi::openmpi
cspice::cspice
)
# We need C++ 20 activated with the concepts library
target_compile_features(spock PUBLIC cxx_std_20)
Problem: undefined reference to sysctl ... on my local system only.
Building on my local machine with CMake 3.23.2 results in the following error message:
Consolidate compiler generated dependencies of target spock
[ 25%] Building CXX object src/CMakeFiles/spock.dir/main.cpp.o
^[[A^[[A[ 50%] Linking CXX executable ../bin/spock
/usr/bin/ld: /home/becheler/.conan/data/openmpi/4.1.0/_/_/package/8f7048d1bf6fc2a7985eb087c34e69a5e64f6c86/lib/libopen-pal.a(evutil_rand.o): in function `arc4_stir.isra.0':
evutil_rand.c:(.text+0x3d2): undefined reference to `sysctl'
collect2: error: ld returned 1 exit status
gmake[2]: *** [src/CMakeFiles/spock.dir/build.make:146: bin/spock] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:135: src/CMakeFiles/spock.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
However, the same build on Github workflows on Ubuntu 20.04 works. What is weird. The only difference before apart the distribution version is that github wokflows use higher privileges than me on local (I believe?).
What I tried so far
I've been trying to read about what this sysctlreference is. And I found conflicting information:
Frrom this man page:
The sysctl() function retrieves system information and allows processes with appropriate privileges to set system information.
this similar SO question came to the conclusion that
Linux does not support this function (other OS like MacOS or FreeBSD support it)
A comment from the same post concludes that in Linux,
these details can be obtained by reading the kernel-provided
pseudofiles /proc/cpuinfo and /proc/meminfo
So here is my question: why does it compile at all on the remote server if this command is not supposed to exist on the OS used?
Im having problem when i build a fresh project , nothing was added/ remove; i get an error no such file or directory 'atomic'
So i investigate a bit and i kind of found the culprit on the makefile. on line 43
line 43: LIBS = $(SUBLIBS) /opt/Qt/6.2.3-armv7l/lib/libQt6Quick.so /opt/Qt/6.2.3-armv7l/lib/libQt6OpenGL.so /opt/Qt/6.2.3-armv7l/lib/libQt6Gui.so -lEGL /opt/Qt/6.2.3-armv7l/lib/libQt6QmlModels.so /opt/Qt/6.2.3-armv7l/lib/libQt6Qml.so -pthread /opt/Qt/6.2.3-armv7l/lib/libQt6Network.so /opt/Qt/6.2.3-armv7l/lib/libQt6Core.so -latomic -lpthread -lGLESv2 atomic
removing word "atomic" at the end removes the error but im not sure if this is the right thing to do as it might cause some weird bugs under the hood. Qt says the line causing the error is line 228
line 227: untitled: $(OBJECTS)
line 228: $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
How do i properly solve this issue?
I am using qt 6.2
Since this is a fresh unmodified project the .pro is also at default
QT += quick
CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
It seems that you are building Qt6 on a Raspberry PI, which isn't an official supported platform.
Does removing atomic may result in some weird bugs?
No, that shouldn't be the case. A missing needed libraries would result in a link time error, not a runtime error.
Off course, since Raspberry PI isn't a supported platform, weird things may happen because it is not (well) tested on this platform, but this will not be related to removing the atomic library.
It seems to me a bug in the Makefile generation code, as library are normally specified using the -l option (which searches for the lib in the specified library search path), instead of providing the relative path to the library. As pointed out in the comments -latomic is also specified. So, atomic seems to be unneeded.
Why does Qt report the error at line 228?
Because this is the line that generates the full linker statement that is being executed. Line 43 is included by $(LIBS).
Tracking the root cause
Searching for atomic inside your (modified) source code of Qt may point you why this library is added to the LIBS variable. The best solution is to remove it at that place.
Relevant resources
Note that this issue is already discussed here.
I'm trying to build an application using the Yocto SDK. The compilation worked well, but when it comes to linking, following linker errors occurs:
...
/opt/mydistro/1.0.0/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.3.0/real-ld: /opt/mydistro/1.0.0/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/lib/libc.a(getcontext.o): in function `getcontext':
/usr/src/debug/glibc/2.29-r0/git/stdlib/../sysdeps/unix/sysv/linux/arm/getcontext.S:101: undefined reference to `_rtld_global_ro'
/opt/mydistro/1.0.0/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.3.0/real-ld: /opt/mydistro/1.0.0/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/lib/libc.a(setcontext.o): in function `__startcontext':
/usr/src/debug/glibc/2.29-r0/git/stdlib/../sysdeps/unix/sysv/linux/arm/setcontext.S:100: undefined reference to `_rtld_global_ro'
collect2: error: ld returned 1 exit status
makefile:116: recipe for target 'ortable' failed
make: *** [ortable] Error 1
I have really no clue, why the object '_rtld_global_ro' cannot be found. Could someone tell me what is going wrong and what I can do to link the application, please? Maybe, there is a workaround for this?
Other applications could be build with same setup without this issue (sourcing the SDK using following command):
source /opt/mydistro/1.0.0/environment-setup-cortexa9t2hf-neon-poky-linux-gnueabi
Here is the image bb file (which I have used for building the SDK using the command bitbake my-image -c populate_sdk).
require recipes-extended/images/core-image-full-cmdline.bb
IMAGE_INSTALL_append = " \
emmy-w1-driver-sdiosdio \
emmy-w1-systemd \
eth-systemd \
can-systemd \
can-utils \
lighttpd \
dnsmasq \
parted \
swupdate \
swupdate-www \
u-boot-fw-utils \
linux-firmware-imx-sdma-imx6q \
"
TOOLCHAIN_HOST_TASK_append = " nativesdk-perl-modules"
SDKIMAGE_FEATURES_append = " staticdev-pkgs"
This is an issue in the upstream glibc sources: The ARM assembler version of setcontext assumes that all PIC code is dynamic linked, which means that static linking fails if glibc was built in static PIE mode (because that actives PIC without providing the dynamic linker code).
You either need to build glibc without static PIE support (I did not even know this was a supported configuration for 32-bit ARM), or replace the PIC macro with SHARED in sysdeps/unix/sysv/linux/arm/setcontext.S.
I tried to compile PESTC using this configuration:
./configure --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-f-blas-lapack=1 --download-openmpi --with-shared-libraries
make PETSC_DIR=/tmp/petsc-3.3-p7 PETSC_ARCH=arch-linux2-c-debug all
But when compiling my lib that uses petsc, even though I linked all petsc libs it's complain at runtime of: undefined symbol: _Z10VecGetSizeP6_p_VecPi, and after some search in the interne I came across some .so that my petsc didn't build, libs like libpetscvec.so or libpetscsnes.so.
I also found that it will generate some .mod with the same name of these non-generated libs (ex: /tmp/petsc-3.3-p7/arch-linux2-c-debug/include/petscsnes.mod).
so I'm not sure if I'm missing a flag that should tell the compiler to give me libs no modules, or maybe if they are in some external packages, and that I should install with --download-SOMEPACKAGE.
Here is the .so libs that are generated in the $PETSC_DIR/$PETSC_ARCH/lib:
libmca_common_sm.so
libmca_common_sm.so.1
libmca_common_sm.so.1.0.2
libmpi.so
libmpi.so.0
libmpi.so.0.0.4
libmpi_cxx.so
libmpi_cxx.so.0
libmpi_cxx.so.0.0.1
libmpi_f77.so
libmpi_f77.so.0
libmpi_f77.so.0.0.3
libmpi_f90.so
libmpi_f90.so.0
libmpi_f90.so.0.1.0
libopen-pal.so
libopen-pal.so.0
libopen-pal.so.0.0.0
libopen-rte.so
libopen-rte.so.0
libopen-rte.so.0.0.0
libopenmpi_malloc.so
libopenmpi_malloc.so.0
libopenmpi_malloc.so.0.0.0
libpetsc.so
This one was quite trick here is how I solved it:
./configure --with-pic=1 \
--with-x11=0 --download-openmpi=yes \
--doCleanup=1 --useThreads=0 \
--with-shared-libraries=1 --with-clanguage=Cxx \
--with-c++-support --with-fc=0 --ignore-cygwin-link \
--with-blas-lib="[$VENDOR_LIBS/intel/mkl/lib/intel64/libmkl_blas95_lp64.a,$VENDOR_LIBS/intel/mkl/lib/intel64/libmkl_intel_lp64.so,$VENDOR_LIBS/intel/mkl/lib/intel64/libmkl_core.so,$VENDOR_LIBS/intel/mkl/lib/intel64/libmkl_intel_thread.so,$VENDOR_LIBS/intel/lib/intel64/libiomp5.so]" \
--with-lapack-lib="[$VENDOR_LIBS/intel/mkl/lib/intel64/libmkl_lapack95_lp64.a]"
So, yes, I saw that I was missing the Intel MKL libraries (that was a big part of the error, but also was the rest of the arguments passed in the configure).
I'm not sure if this is something that will be useful for others, since this lib has tons of different configurations for many cases. But, hey, who knows...
I have used CMake to make a library and then made a test exe. After building, I would like to automatically run my test cases. Here is my CMakeLists.txt. It makes the .exe OK but does not run it. I am using Linux.
cmake_minimum_required (VERSION 2.8.7)
project (tests)
set(LIBRARY_NAME exetests)
set(LIBRARY_SOURCES RunAllTests.cpp Tests.cpp )
set(CMAKE_CXX_FLAGS "-fPIC -Werror -O2 -std=c++0x -g")
add_executable(exetests ${LIBRARY_SOURCES})
target_link_libraries(exetests CppUTest )
target_link_libraries(exetests CppUTestExt )
target_link_libraries(exetests testLibrary )
#THIS IS WRONG. EXE is not Run
add_custom_target( COMMAND ./exetests )
You can use CTest for testing of executables created by CMake. In your CMakeLists.txt, use commands enable_testing and add_test
...
enable_testing()
...
add_executable(exetests ${LIBRARY_SOURCES})
...
add_test(NAME mytest1 COMMAND exetests)
in your binary directory, compile make exetests and run testing by ctest. Some additional information could be found on CMake Wiki.
From the documentation:
The second signature adds a custom command to a target such as a library or executable. This is useful for performing an operation before or after building the target. The command becomes part of the target and will only execute when the target itself is built. If the target is already built, the command will not execute.
add_executable(RunAllTests RunAllTests.cpp)
target_link_libraries(RunAllTests imp_cpputest LedDriverTest LedDriver sprintfTest RuntimeErrorStub)
add_custom_command( TARGET RunAllTests COMMAND cd ../bin && ./RunAllTests POST_BUILD)