More of a General Linux Question Directed at the BBB with .a Libraries

General Linux Stuff if Anyone is Interested,

So, there are about 15 files which all compiled as a static library (.a).

My Makefile does not have an install mechanism in it to sudo make install the library since it is static.

Would I need to make an addition to the Makefile to handle install? Also, when compiling against the static library, I seem to be getting random errors found below:

/usr/local/lib/BeagleCPP.a: line 1: syntax error near unexpected token `newline'
/usr/local/lib/BeagleCPP.a: line 1: `!<arch>'

My script to build the used file against the static library seems to an issue or it is a static library concern…

The file script to build against the static library is here:

/usr/local/lib/BeagleCPP.a -larm-linux-gnueabihf- -lpthreads Listing_1.1.cpp -o Listing_1.1.out

I am messing with building Mr. Gaona’s BeagleCPP library but using a different approach.

Seth

P.S. I know I have gone off the deep end to say the least, e.g. tell-tale signs from my last three or four posts clued you in. Right? So, any ideas would be welcomed.

The static library was not linked with pthreads but I am calling it to handle specifics within the static library (.a). More about pthreads can be found here: pthreads(7) - Linux manual page

Am I calling the build script incorrectly or is linking the pthreads and the static library needed too?

Okay…

Update to my weird way of working here…

So, I bailed on the Makefile business. Has it been successful so far? NO!

Can I attempt to make it so you can better understand what it is exactly I am getting at now? YES!

cmake --build .
[  5%] Building CXX object CMakeFiles/BeagleCPP.dir/src/ADC.cpp.o
[ 10%] Building CXX object CMakeFiles/BeagleCPP.dir/src/BUTTON.cpp.o
[ 15%] Building CXX object CMakeFiles/BeagleCPP.dir/src/CONTINUOUS_SERVO.cpp.o
[ 21%] Building CXX object CMakeFiles/BeagleCPP.dir/src/DCMOTOR.cpp.o
[ 26%] Building CXX object CMakeFiles/BeagleCPP.dir/src/DCMOTOR_UTILS.cpp.o
[ 31%] Building CXX object CMakeFiles/BeagleCPP.dir/src/GPIO.cpp.o
[ 36%] Building CXX object CMakeFiles/BeagleCPP.dir/src/HC_SR04.cpp.o
[ 42%] Building CXX object CMakeFiles/BeagleCPP.dir/src/KEYPAD_5BUTTONS.cpp.o
[ 47%] Building CXX object CMakeFiles/BeagleCPP.dir/src/L298N.cpp.o
[ 52%] Building CXX object CMakeFiles/BeagleCPP.dir/src/LED.cpp.o
[ 57%] Building CXX object CMakeFiles/BeagleCPP.dir/src/LM35.cpp.o
[ 63%] Building CXX object CMakeFiles/BeagleCPP.dir/src/MISCELLANEOUS.cpp.o
[ 68%] Building CXX object CMakeFiles/BeagleCPP.dir/src/POSITION_SERVO.cpp.o
[ 73%] Building CXX object CMakeFiles/BeagleCPP.dir/src/PWM.cpp.o
[ 78%] Building CXX object CMakeFiles/BeagleCPP.dir/src/SERVO.cpp.o
[ 84%] Building CXX object CMakeFiles/BeagleCPP.dir/src/STEPPER.cpp.o
[ 89%] Building CXX object CMakeFiles/BeagleCPP.dir/src/SYSFILEACCESS.cpp.o
[ 94%] Building CXX object CMakeFiles/BeagleCPP.dir/src/TB6612FNG.cpp.o
[100%] Linking CXX executable BeagleCPP

As you can see, my linker is stuck in x86_64 land for now.

My make command after the initial set, below, of commands gets altered but not in my way (arm-linux-gnueabihf-):

mkdir build && cd build
cmake -DCROSS_COMPILE=/usr/bin/arm-linux-gnueabihf-g++ ..
    // the cmake command only accepts CMakeLists.txt commands for now
    // so, the -D option is out for now without compiling it into the CMakeLists.txt
cmake --build .

I feel I am getting closer so building the library, i.e. as the 100% is marked outside of a small fiasco with the linker issue.

Seth

P.S. Here is the error in case anyone sees my argument without me viewing it via research just yet…

[  5%] Linking CXX executable BeagleCPP
/usr/lib/gcc-cross/arm-linux-gnueabihf/12/../../../../arm-linux-gnueabihf/bin/ld: /usr/lib/gcc-cross/arm-linux-gnueabihf/12/../../../../arm-linux-gnueabihf/lib/Scrt1.o: in function `_start':
(.text+0x30): undefined reference to `main'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/BeagleCPP.dir/build.make:369: BeagleCPP] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/BeagleCPP.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2

I think there are some tricks in the files I have not witnessed or forget to witness for now. I will keep trying. If anyone sees an error or errors I am missing, please let me know.

Okay. So, I have not made anyone understand anything about what I am doing. Okay.

I will try better this time:

cmake_minimum_required(VERSION 3.25)
project(BeagleCPP)

# find_package(PTHREADS REQUIRED)

set(CMAKE_CXX_STANDARD 17)

set(CMAKE_SYSTEM_NAME Linux)

set(CMAKE_C_COMPILER   /usr/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(CMAKE_FIND_ROOT_PATH ~/BeagleCPP/)

include_directories(include)

file(GLOB SOURCES "src/*.cpp")

add_executable(BeagleCPP ${SOURCES})

That is my CMakeLists.txt file for building with cmake. The configuration goes well and then I get hit with a ton of bricks for some reason during the building of the files in question…

If you see my error, please splish-splash your way to me.

I seem to not understand a process in which I entail to complete thus far. So, just a recap:

  • I am building a static library out of the already produced source from Mr. Gaona and his work.
  • So, instead of building a .so file, I am building the .a replacement and coming up short in the build.

Um, so yep. I think that about covers it.

Seth

P.S. Any ideas that are prevalent will work, i.e. as I am hunting down the correct error in disguise.

  • Update

  • I think trying to duplicate the build on the BBB may provide additional solutions instead of trying to cross_compile the build in WSL2. Aw. BBWR (be back with reports). Oh…

I see…

ELDK is out of bounds now or something…argh.

Another Update

So, I started a cmake discourse question since this mostly applies to Linux in general and cmake builds with my_toolchain.cmake .. for the build process… So, no worries.