Problem in Cross-Compiling libSDL for MIPS Platform - linux

I was trying to compile libSDL-1.2.14 for my mips platform.
But it was not successful.
These were the steps that I tried out :
export PATH=/opt/mips-4.3/bin:$PATH
Went inside the libSDL-1.2.14 source folder.
Gave a "./configure --prefix=/usr/local/SDL_Lib --host=mips-linux-gnu"
Executed the "make" command
This was the error received :
cc1: warning: include location
"/usr/include" is unsafe for
cross-compilation
./src/audio/dma/SDL_dmaaudio.c: In
function 'DMA_WaitAudio':
./src/audio/dma/SDL_dmaaudio.c:167:
error: can't find a register in class
'COP3_REGS' while reloading 'asm'
./src/audio/dma/SDL_dmaaudio.c:167:
error: 'asm' operand has impossible
constraints make: *
[build/SDL_dmaaudio.lo] Error 1
But then i reconfigured the make file by giving the following commands :
make clean
./configure --prefix=/usr/local/SDL_Lib --host=mips-linux-gnu CPPFLAGS=-I/opt/mips-4.3/mips-linux-gnu/libc/usr/include/
make
NOTE : /opt/mips-4.3/mips-linux-gnu/libc/usr/include/ - This is the path where you can locate the select.h file for the mips Platform.
It contains the definitions of the macros FD_ZERO and FD_SET.
Still I am getting the same error.
cc1: warning: include location
"/usr/include" is unsafe for
cross-compilation
./src/audio/dma/SDL_dmaaudio.c: In
function 'DMA_WaitAudio':
./src/audio/dma/SDL_dmaaudio.c:167:
error: can't find a register in class
'COP3_REGS' while reloading 'asm'
./src/audio/dma/SDL_dmaaudio.c:167:
error: 'asm' operand has impossible
constraints make: *
[build/SDL_dmaaudio.lo] Error 1
Please help me with some valuable pointers.
Thanks,
Sen

First, don't set the path to the cross-compiler as the first part of your PATH, set it as last:
export PATH=$PATH:<path to cross-compiler>
It's safer this way. Second, run ./configure --help to get all the options. What that error message would say if it was smarter is the following:
You're trying to cross-compile since you're setting the --host flag
But you're not changing any of the other options for where to find includes and libs for the target environment
I'm going to use /usr/include by default
But that's for the host system which will not work when cross-compiling
Check what other configure options you need to set to tell the configure script where to find the .h files (includes) and the libraries for your target. These usually come with the cross-compiler that you download. Also, you should probably set the CROSS_COMPILE environment variable to the cross-compiler prefix before running configure. The prefix is the part before gcc in a cross-compiler, assuming you're using GCC as your cross-compiler.

Related

Why does/can my build access sysctl on Linux?

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?

Run ./configure from bash script fails due "error: cannot compute suffix of object files"

I'm trying to automate some stage of compile/build on Linux RHEL7 host using a bash script, but when i try to use ./configure it fails due to :
configure:3793: error: in `/app/compiling/BUILD_AREA/TEST/SRC/zabbix-4.2.6':
configure:3795: error: cannot compute suffix of object files: cannot compile
using :
CC="gcc"
PATH="/app/app_lib/mysql/bin:/app/app_lib/bin:/app/app_lib/build-1:/app/app_lib:$PATH"
LD_LIBRARY_PATH="/app/app_lib:/app/app_lib/include:/app/app_lib/lib:/app/apache/modules:/app/app_lib/ssl:/app/app_lib/lib/iconv:/app/oracle/product/12.1.0/lib:/app/ap_lib/mysql/lib:$LD_LIBRARY_PATH"
export CC
export PATH
export LD_LIBRARY_PATH
ARG_ZABBIX="--prefix=/app/zabbix --datarootdir=/app/zabbix/share --docdir=/app/zabbix/share/doc/$PKGAPPDIR --enable-agent --enable-ipv6 --enable-java --enable-server --includedir=/app/zabbix/include --libdir=/app/zabbix/lib --mandir=/app/zabbix/share/man/$PKGAPPDIR --with-libcurl=/app/app_lib/bin/curl-config --with-libxml2=/app/app_lib/bin/xml2-config --with-mysql=/app/mysql/bin/mysql_config --with-net-snmp=/app/app_lib/bin/net-snmp-config --with-openipmi=/app/app_lib --with-ssh2=/app/app_lib"
CONFIGURE="configure"
cd /app/compiling/BUILD_AREA/TEST/SRC/zabbix-4.2.6
"./${CONFIGURE}" "${ARG_ZABBIX}" 2>&1
Any help would be really appreciated!
Any help would be really appreciated!
Find the respective config.log (like the one in $(builddir)/gcc) and have a look. Some configure tests might fail as configure is querying availability of host features; the relevant fail is usually recorded at the end of the relevant config.log.
A common cause for this error is that the target Binutils (as, the assembler) cannot be found as configure is trying to find out what suffix to use for object files. Or host as is used where actually the target as (as of --target=) should be used, and the host as throws a syntax error because it is fed with target assembly.
./configure
GCC does not support configuring in the source directory or any of its sub-folders:
"First, we highly recommend that GCC be built into a separate directory from the sources which does not reside within the source tree."

IP multimedia subsystem cross compilation

I am using OpenIMSCore on x86 architecture. I need to cross compile OpenIMS for power-pc. In /ser_ims/Makefile.defs file there is a option for ppc. But I am not able to figure out how to cross compile it for ppc. There is no configure file through which I can configure IMS and compile it for ppc. Has anyone cross compiled IMS? I tried compiling through command
make CFLAGS="arch=Power Macintosh"
make CFLAGS="arch=ppc"
But both the commands are not working. It is giving following error:
Makefile.defs:598: You are using an old and unsupported gcc version (G++), compile at your own risk!
powerpc-linux-gnu-gcc -g -O9 -funroll-loops -Wcast-align -Wall -DNAME='"ser"' -DVERSION='"2.1.0-dev1 OpenIMSCore"' -DARCH='"i386"' -DOS='linux_' -DOS_QUOTED='"linux"' -DCOMPILER='"powerpc-linux-gnu-gcc G++"' -D__CPU_i386 -D__OS_linux -DSER_VER=2001000 -DCFG_DIR='"/usr/local/etc/ser/"' -DPKG_MALLOC -DSHM_MEM -DSHM_MMAP -DDNS_IP_HACK -DUSE_IPV6 -DUSE_MCAST -DUSE_TCP -DDISABLE_NAGLE -DHAVE_RESOLV_RES -DDBG_QM_MALLOC -DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -ggdb -DUSE_TLS -DTLS_HOOKS -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 -DCC_GCC_LIKE_ASM -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM -DHAVE_EPOLL -DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND -DHAVE_SELECT -c core_cmd.c -o core_cmd.o
core_cmd.c: In function 'core_shmmem':
mem/../fastlock.h:181: error: can't find a register in class 'MQ_REGS' while reloading 'asm'
mem/../fastlock.h:358: error: can't find a register in class 'MQ_REGS' while reloading 'asm'
mem/../fastlock.h:181: error: can't find a register in class 'MQ_REGS' while reloading 'asm'
mem/../fastlock.h:181: error: 'asm' operand has impossible constraints
Probably, the error you are getting is due to the separate header file definition and most importantly different shared library files for x86 architecture and different header files for PowerPC architecture. You can change the header file definitions with the new ones using "-I" flag and the shared library file path which is for PowerPC architecture, which can be changed by using -L option. But these all changes might be implemented in Makefile, so u just need to change the location in different flags, like LDFLAG, CFLAGS etc.

Ant LibusbJava compile error: "jni.h: No such file"...fixed, now a memset error

There appears to be a Ant / jni.h problem (for my setup) with LibusbJava. I get the following error when setting up LibusbJava by running
ant linux
in CentOS 6.3 as root (quick and dirty test, thanks for those concerned about user level =0). I will redo with proper restrictions as shown on a libusbjava reference after reflection when first install works. LibusbJava, is a Java wrapper for the libusb library.
The output starts out like this:
[root#somebox LibusbJava]# ant linux -lib $JAVA_HOME/include -lib $JAVA_HOME/include/linux
Buildfile: build.xml
clean:
Build LibusbJava Test Linux:
Build LibusbJava Test:
[echo] Building Library for unit tests:
[exec] /.../libusbjava/trunk/LibusbJava/LibusbJava.cpp:27:17: error: jni.h: No such file or directory
[exec] /.../libusbjava/trunk/LibusbJava/LibusbJava.cpp:34:26: error: test/CuTest.h: No such file or directory
`...`
as it was not set on my system. It appears that jni.h is a header called by C++ code, which I had to add to the LibusbJava.cpp file. This is the new include, /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/include/jni.h. I then get an error with jni.h not being able to fine jni_md.h which is an include in jni.h #include "jni_md.h".
Clearly this is not the right approach, so perhaps I need a correct Ant reference, but I cannot seem to do it with a -lib switch. Besides, this just creates thousands of jni.h file errors during the Ant build attempt.
How can I fix this problem?
Notes: I've set$JAVA_HOME up like JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64 and javac and java work fine.
New discovery... after helpful questions which guided me, I am much closer to successful compilation.
When I install LibusbJava and manually install all the library references in build.xml there is still an error compiling the LibusbJava based on a memset error. I see memset patches for libusb that appeared in 2007 and it's unclear how to use or if they relate. Investigating... Hints, comments and questions welcome. My most sincere thanks for the help thus far.
[exec] /.../libu/libusbjava/trunk/LibusbJava/objects/Usb_Device.cpp: In function ‘void Usb_Device_disconnect(JNIEnv*)’:
[exec] /.../libu/libusbjava/trunk/LibusbJava/objects/Usb_Device.cpp:88: error: ‘memset’ was not declared in this scope
[antcall] Exiting /.../libu/libusbjava/trunk/LibusbJava/build.xml.
BUILD FAILED
but I find no referece to an include string.h or cstring. The header of Usb_Device.cpp mentions it is a C++ Stub for the java class of a java class ch.ntb.inf.libusbJava.Usb_Device. which only has this include #include "Usb_Device.h" which also does not appear to have a string include. Perhaps just insertion of#include`?

CMake finds the correct library, but VC++ attempts to link with something else

I have a CMake module to locate FreeGLUT:
FIND_PATH(FREEGLUT_INCLUDE_DIR NAMES GL/freeglut.h)
FIND_LIBRARY(FREEGLUT_LIBRARY NAMES freeglut freeglut_static)
SET(FREEGLUT_LIBRARIES ${FREEGLUT_LIBRARY})
SET(FREEGLUT_INCLUDE_DIRS ${FREEGLUT_INCLUDE_DIR})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FreeGLUT DEFAULT_MSG FREEGLUT_LIBRARY FREEGLUT_INCLUDE_DIR)
MARK_AS_ADVANCED(FREEGLUT_INCLUDE_DIR FREEGLUT_LIBRARY)
It works fine and locates freeglut_static.lib when I generate NMake Makefiles on Windows. I'm attempting to statically link FreeGLUT into my DLL:
FIND_PACKAGE(FreeGLUT REQUIRED)
ADD_LIBRARY(vti SHARED ${VTI_SOURCES})
ADD_DEFINITIONS("-DBUILD_VTI=1 -DFREEGLUT_STATIC=1")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${FREEGLUT_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(vti ${FREEGLUT_LIBRARIES})
My source code builds correctly, but when it gets to the linking stage, VC++ fails with:
LINK : fatal error LNK1104: cannot open file 'freeglut.lib'
Which is strange since freeglut.lib isn't mentioned anywhere that I can see in the generated NMake makefiles. It should be trying to link with freeglut_static.lib, which CMake locates and sets in FREEGLUT_LIBRARIES.
What might be causing this?
This is caused with pragma directives in FreeGLUT code (see freeglut_std.h). Using FREEGLUT_STATIC should really fix that for you, but I think you should pass it to CMake without quotes: ADD_DEFINITIONS(-DBUILD_VTI -DFREEGLUT_STATIC)

Resources