You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2023/01/12 16:49:18 UTC

[GitHub] [logging-log4cxx] LOCNNIL opened a new issue, #176: Error Cross-compiling library

LOCNNIL opened a new issue, #176:
URL: https://github.com/apache/logging-log4cxx/issues/176

   I'm trying to cross compile the **log4cxx** lib for an armv7l arch.
   
   # Steps to reproduce:
   
   ### Install the cross tolchain arm-linux-gnueabi
   ```bash
   sudo apt install -y gcc-arm-linux-gnueabi g++-arm-linux-gnueabi binutils-arm-linux-gnueabi
   ```
   
   ### Start some env variables to hold directores
   ```bash
   export DIR_TARGET=/data/marthe/usr
   export DIR_HOST=$HOME/project/lib/expat
   ```
   
   ## **Expat** dependency library
   ```bash
   wget https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.gz
   ## Extract the source code
   tar -xvf expat-2.5.0.tar.gz
   cd expat-2.5.0
   ```
   
   #### Configuring
   ```bash
   ./configure \
   --build=i686-pc-linux-gnu \
   --host=arm-linux-gnueabi \
   --prefix=$DIR_HOST \
   --exec-prefix=$DIR_HOST \
   STRIP="/usr/bin/arm-linux-gnueabi-strip" \
   AR="/usr/bin/arm-linux-gnueabi-ar" \
   CC="/usr/bin/arm-linux-gnueabi-gcc -march=armv7-a -mfloat-abi=softfp -mfpu=neon" \
   CXX="/usr/bin/arm-linux-gnueabi-g++ -march=armv7-a -mfloat-abi=softfp -mfpu=neon" \
   CFLAGS="-O3 -fexpensive-optimizations -frename-registers -fomit-frame-pointer" \
   CXXFLAGS="-O3 -fexpensive-optimizations -frename-registers -fomit-frame-pointer" \
   LDFLAGS="-Wl,--strip-all -Wl,--rpath=$DIR_TARGET/lib -Wl,--dynamic-linker=$DIR_TARGET/lib/ld-linux.so.3 -Wl,-O3 -Wl,--hash-style=gnu -Wl,--as-needed" \
   CPP="/usr/bin/arm-linux-gnueabi-gcc -E -march=armv7-a -mfloat-abi=softfp -mfpu=neon" \
   CXXCPP="/usr/bin/arm-linux-gnueabi-g++ -E -march=armv7-a -mfloat-abi=softfp -mfpu=neon" \
   STRIP="/usr/bin/arm-linux-gnueabi-strip" \
   OBJDUMP="/usr/bin/arm-linux-gnueabi-objdump"
   
   make -j4 
   
   make install
   ```
   
   
   ## Log4cxx instalation
   
   
   ### Downloading and extracting source code
   ```bash
   wget https://dlcdn.apache.org/logging/log4cxx/1.0.0/apache-log4cxx-1.0.0.tar.gz
   tar -xvf apache-log4cxx-1.0.0.tar.gz
   cd  apache-log4cxx-1.0.0
   ```
   
   ### Configuring
   ```bash
   cmake -Bbuild -H. \
     -DCMAKE_BUILD_TYPE=Release \
     -DCMAKE_INSTALL_PREFIX=$HOME/project/lib/log4cxx \
     -DCMAKE_TOOLCHAIN_FILE=$HOME/project/cmake/toolchain-arm-linux-gnueabi.cmake \
     -DBUILD_TESTING=off \
     -DBUILD_SHARED_LIBS=off \
     -DEXPAT_LIBRARY=$HOME/project/lib/expat/lib \
     -DEXPAT_INCLUDE_DIR=$HOME/project/lib/expat/include \
     -G "Unix Makefiles"
   
   ```
   
   
   # Error from configuration step
   
   ```
   -- Available appenders:
   --   Async Appender .................. : ON
   --   ODBC Appender ................... : OFF
   --   SMTP Appender ................... : OFF
   --   XMLSocketAppender ............... : ON
   --   SocketHubAppender ............... : ON
   --   SyslogAppender .................. : ON
   --   TelnetAppender .................. : ON
   --   NTEventLogAppender .............. : OFF
   --   OutputDebugStringAppender ....... : ON
   --   ConsoleAppender ................. : ON
   --   FileAppender .................... : ON
   --   RollingFileAppender ............. : ON
   --   MultiprocessRollingFileAppender . : OFF
   -- Available layouts:
   --   HTMLLayout ...................... : ON
   --   JSONLayout ...................... : ON
   --   PatternLayout ................... : ON
   --   SimpleLayout .................... : ON
   --   XMLLayout ....................... : ON
   --   FMTLayout ....................... : OFF
   CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
   Please set them or make sure they are set and tested correctly in the CMake files:
   /home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/src/APR_INCLUDE_DIR
      used as include directory in directory /home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/src/main/cpp
   /home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/src/APR_UTIL_INCLUDE_DIR
      used as include directory in directory /home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/src/main/cpp
   
   -- Configuring incomplete, errors occurred!
   See also "/home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/build/CMakeFiles/CMakeOutput.log".
   See also "/home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/build/CMakeFiles/CMakeError.log".
   ```
   
   these are the log files of the errors:
   
   [CMakeError.log](https://github.com/apache/logging-log4cxx/files/10403684/CMakeError.log)
   [CMakeOutput.log](https://github.com/apache/logging-log4cxx/files/10403685/CMakeOutput.log)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] LOCNNIL commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by GitBox <gi...@apache.org>.
LOCNNIL commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1381739897

   Currenty to find the libraries and compile the code I'm using the Cmake file `toolchain-arm-linux-gnueabi.cmake` that points to my toolchain.
   
   This is my toolchain file:
   
   ```cmake
   set(CMAKE_SYSTEM_PROCESSOR arm)
   set(CMAKE_SYSTEM_NAME Linux)
   set(CMAKE_SYSTEM_VERSION 1)
   
   set(cpu_flags "-march=armv7-a -mfloat-abi=softfp -mfpu=neon")
   set(c_cxx_flags " -O2 -fexpensive-optimizations -frename-registers -fomit-frame-pointer -pthread")
   
   set(CMAKE_C_COMPILER   /usr/bin/arm-linux-gnueabi-gcc ${cpu_flags})
   set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabi-g++ ${cpu_flags})
   
   set (CMAKE_SHARED_LINKER_FLAGS "-Wl,-start-group -lpthread -lm -Wl,-end-group -Wl,--rpath=${target_dir}/lib -Wl,--dynamic-linker=${target_dir}/lib/ld-linux.so.3 -Wl,-O3 -Wl,--hash-style=gnu -Wl,--as-needed")
   
   set(CMAKE_C_FLAGS ${c_cxx_flags})
   set(CMAKE_CXX_FLAGS ${c_cxx_flags})
   set(CMAKE_STRIP /usr/bin/arm-linux-gnueabi-strip)
   set(CMAKE_FIND_ROOT_PATH  /usr/arm-linux-gnueabi)
   set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
   set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
   set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
   ```
   
   I realized that my toolchain file was missing the specification `-pthread` to tell the compiler that I'm going to use the **thread** library. Also the linker flag `-lpthread` but this last is only for the linker and don't map the macros inside the library so I had to use both.
   
   But now I'm with a **different** error. It's a linking error too saying that:
   
   ```bash
   cannot find -lesmtp
   ```
   
   So now I'm going to cross compile libESMTP. But first, is this library realy necessary or just used for some feature? If so, is there an Cmake option where I can disable it?
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] LOCNNIL commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by GitBox <gi...@apache.org>.
LOCNNIL commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1383045132

   > > CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
   > > Please set them or make sure they are set and tested correctly in the CMake files:
   > > /home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/src/APR_INCLUDE_DIR
   > > used as include directory in directory /home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/src/main/cpp
   > > /home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/src/APR_UTIL_INCLUDE_DIR
   > 
   > You need to build APR and APR-UTIL with your cross-compiler.
   > 
   > To cross-compile APR you will need a triplet file that locates the tool chain and sets --host and --cache parameters of "./configure". The .cache file must have been generated on the targeted host using "./configure -C".
   
   Okay, I'm going to try this! But just one question, did the ./configure -C compiles something on my environment or just use some coreutils and other simple things? Because my target (which is also my host) environment it's pretty limited. It's a embedded armv7l running with BusyBox.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] Zaoui-Douaa commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by "Zaoui-Douaa (via GitHub)" <gi...@apache.org>.
Zaoui-Douaa commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1527003104

   how can i build log4cxx with linux arm cortex A9 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] rm5248 commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by GitBox <gi...@apache.org>.
rm5248 commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1383045125

   > So if I just comment this part I will be able to cross-compile successfully? If yes, I'll gonna try it and post here the results.
   
   That seems like a good thing to try.
   
   > Okay, I'm going to try this! But just one question, did the `./configure -C` compiles something on my environment or just use some coreutils and other simple things? Because my target (which is algo my host) environment it's pretty limited. It's a embedded armv7l running with BusyBox.
   
   I have no idea - I have found cross-compiling is hard to setup correctly.  If the build scripts are not setup correctly it may not work.  In theory, cross-compiling only checks things in the rootfs(e.g. include files, libraries).  You may also need to worry about the `--sysroot` option for GCC.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] LOCNNIL commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by GitBox <gi...@apache.org>.
LOCNNIL commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1383043657

   > 
   
   Okay, I'm going to try this! But just one question, did the `./configure -C` compiles something on my environment or just use some coreutils and other simple things? Because my target (which is algo my host) environment it's pretty limited. It's a embedded armv7l running with BusyBox.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] swebb2066 commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by GitBox <gi...@apache.org>.
swebb2066 commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1383057644

   The autotools `./configure -C` does a lot of stuff, including trying to compile some code.
   
   As BusyBox does not support gcc, you will need to hack a cache file generated on some other armv7 machine (say a raspberrypi).
   
   Perhaps you should also look at [https://github.com/apache/apr/pull/8](this old PR)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] rm5248 closed issue #176: Error when Cross-compiling library for ARMv7l

Posted by "rm5248 (via GitHub)" <gi...@apache.org>.
rm5248 closed issue #176: Error when Cross-compiling library for ARMv7l
URL: https://github.com/apache/logging-log4cxx/issues/176


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] swebb2066 commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by GitBox <gi...@apache.org>.
swebb2066 commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1382681660

   On reflection, I am not sure I ever successfully build APR and APR-UTIL with a cross-compiler.
   
   What I found works is to use the conan package manager (and a Artifactory server from JFrog). This allows APR and APR-UTIL to be built on the native system and uploaded to the server for use in cross-compilation builds. 
   
   The conan package manager can be used to install APR and APR-UTIL from the remote  Artifactory server.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] rm5248 commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by "rm5248 (via GitHub)" <gi...@apache.org>.
rm5248 commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1527956454

   If you have a specific issue compiling, please create a new issue.  Every system is different, but the process of cross-compiling should be similar for all systems.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] LOCNNIL commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by GitBox <gi...@apache.org>.
LOCNNIL commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1383042835

   > libESMTP is completely optional.
   > 
   > If it's complaining about that, you likely have it installed on your build system - it is only used if it is found.
   > 
   > The check happens [here](https://github.com/apache/logging-log4cxx/blob/master/src/main/include/CMakeLists.txt#L125), perhaps this is not working correctly when cross-compiling.
   
   So if I just comment this part I will be able to cross-compile successfully? If yes, I'll gonna try it and post here the results.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] rm5248 commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by GitBox <gi...@apache.org>.
rm5248 commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1381888942

   libESMTP is completely optional.
   
   If it's complaining about that, you likely have it installed on your build system - it is only used if it is found.
   
   The check happens [here](https://github.com/apache/logging-log4cxx/blob/master/src/main/include/CMakeLists.txt#L125), perhaps this is not working correctly when cross-compiling.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] swebb2066 commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by GitBox <gi...@apache.org>.
swebb2066 commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1382607334

   > CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
   > Please set them or make sure they are set and tested correctly in the CMake files:
   > /home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/src/APR_INCLUDE_DIR
   >    used as include directory in directory /home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/src/main/cpp
   > /home/lincoln/cross_compile/source/apache-log4cxx-1.0.0/src/APR_UTIL_INCLUDE_DIR
   
   You need to build APR and APR-UTIL with your cross-compiler.
   
   To cross-compile APR you will need a triplet file that locates the tool chain and sets --host and --cache parameters of "./configure".
   The .cache file must have been generated on the targeted host using "./configure -C".
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] rm5248 commented on issue #176: Error when Cross-compiling library for ARMv7l

Posted by GitBox <gi...@apache.org>.
rm5248 commented on issue #176:
URL: https://github.com/apache/logging-log4cxx/issues/176#issuecomment-1381120176

   Are you using `pkgconfig` to compile other code and find the libraries?  If I remember correctly you need to set the `PKG_CONFIG_PATH` and/or `PKG_CONFIG_SYSROOT_DIR` variables(see also this [stackoverflow](https://stackoverflow.com/a/9234452) post).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org