Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
178 user(s) are online (163 user(s) are browsing Forums)

Members: 0
Guests: 178

more...

Support us!

Headlines

 
  Register To Post  

How to create clib2 versions of newlib libraries
Not too shy to talk
Not too shy to talk


See User information
Hi all

I am trying to compile freealut for clib2 (newlib version is available on OS4Depot.net)


Is the following CMake command excerpt the right way ? If not how should I do it ?

cmake -DCMAKE_CXX_FLAGS="-mcrt=clib2" -DAMIGAOS4=-DRUN_IN_PLACE=TRUE -DCMAKE_SYSTEM_NAME=GENERIC -DCMAKE_SYSTEM_VERSION=-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="/usr/local/amiga/bin/ppc-amigaos-gcc" -DCMAKE_CXX_COMPILER="/usr/local/amiga/bin/ppc-amigaos-g++" -DCMAKE_LINKER="/usr/local/amiga/bin/ppc-amigaos-ld" -DCMAKE_AR="/usr/local/amiga/bin/ppc-amigaos-ar" -DCMAKE_RANLIB="/usr/local/amiga/bin/ppc-amigaos-ranlib" -DCMAKE_FIND_ROOT_PATH="/usr/local/amiga/ppc-amigaos/"


Edited by SinanSam460 on 2022/9/21 17:54:47
Sinan - AmigaOS4 Beta-Tester
- AmigaOne X5000
- AmigaOne A1222
- Sam460ex
Go to top
Re: How to create clib2 versions of newlib bibraries
Home away from home
Home away from home


See User information
@Sinan
Cmake files can be a bit vary , i.e. in one project CFLAGS_CXX/etc can be taken fine (in most), in some - not. That depends of how CMakeFile's for were done.

Usually, when cmake files in app/game done correctly, it will be something like this:

cd game_dir
mkdir build
cd build

cmake \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_SYSTEM_VERSION=1 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="-mcrt=clib2" \
-DCMAKE_CXX_FLAGS="-mcrt=clib2" \
-DCMAKE_C_COMPILER="/usr/local/amiga/bin/ppc-amigaos-gcc" \
-DCMAKE_CXX_COMPILER="/usr/local/amiga/bin/ppc-amigaos-g++" \
-DCMAKE_LINKER="/usr/local/amiga/bin/ppc-amigaos-ld" \
-DCMAKE_AR="/usr/local/amiga/bin/ppc-amigaos-ar" \
-DCMAKE_RANLIB="/usr/local/amiga/bin/ppc-amigaos-ranlib" \
-DCMAKE_FIND_ROOT_PATH="/usr/local/amiga/ppc-amigaos/" \
..



Things like "-DAMIGAOS4=1" is in use only if in CMakelist.txt you do have "AMIGAOS" thing in which, when this -DAMIGAOS4=1 is set, you do what you need (like add/remove some flags, options, etc which you can from CMake options on running). But "AMIGAOS4" is of course just anything you choose, you can do "-DOMEGA1200=1" , and in main CMakeList.txt add that define.

I for myself didn't use "RUN_IN_PLACE" , so not sure if it default CMake option or not, but when things ported, it anyway always "in place" :)

Most problem is DCMAKE_C_FLAGS and DCMAKE_CXX_FLAGS which not always taken into account, so you may need manually fix CMakeFile to add -mcrt=clib2 where need it, or, alternatively when you build makefiles via cmake, then inside of "flags.txt" and "link.txt" change all you need manually


Edited by kas1e on 2022/9/21 6:16:43
Edited by kas1e on 2022/9/21 6:17:49
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: How to create clib2 versions of newlib libraries
Not too shy to talk
Not too shy to talk


See User information
@kas1e

Ok I can build libalut.a with Cmake command, but I guess it is not the real clib2 version..Because when I compile the project with freealut, I get a __getreent error like this..

From one of past threads, I learned this happen when you mix newlib and clib2 libraries


/usr/local/amiga/ppc-amigaos/SDK/local/clib2/lib/libalut.a(alutError.o): In function `_alutSetError':
/home/salass00/Development/Projects/libs/freealut/src/alutError.c:12: undefined reference to 
`__getreent'
collect2: error: ld returned 1 exit status
make: *** [makefile.os4:319: vanillatd] Error 1


So I tried to create my makefile like this

TARGET         libalut.a
CXX        
ppc-amigaos-gcc

CXXFLAGS     
= -mcrt=clib2 -athread=native -DHAVE_STDINT_H -DHAVE_STAT -DHAVE_NANOSLEEP -DHAVE_TIME_H 
CXXFLAGS    
+= -I/usr/local/amiga/ppc-amigaos/SDK/Local/clib2/include/AL/  -I/usr/local/amiga/ppc-amigaos/SDK/Local/clib2/include/ -I./include 
CXXLIBS        =-L/usr/local/amiga/ppc-amigaos/SDK/Local/clib2/lib/  -lopenal -L/usr/local/amiga/ppc-amigaos/SDK/Local/clib2/lib/libopenal.-lm -lc -lpthread

libalut_la_SOURCES 
=        \
    alutBufferData
.c    \
    alutCodec
.c        \
    alutError
.c        \
    alutInit
.c        \
    alutInputStream
.c    \
    alutInternal
.h        \
    alutLoader
.c        \
    alutOutputStream
.c    \
    alutUtil
.c        \
    alutVersion
.c        \
    alutWaveform
.c

OBJS1 
= $(libalut_la_SOURCES

all: $(TARGET)

$(
TARGET): $(OBJS1)
    $(
CXX) $(CXXFLAGS) -$@ $^ $(CXXLIBS)


and final error is like this:
/usr/local/amiga/ppc-amigaos/SDK/clib2/lib/libc.a(main.o): In function `call_main':
main.c:(.text+0x3c): undefined reference to 
`main'
collect2: error: ld returned 1 exit status
make: *** [Makefile.os4:26: libalut.a] Error 1


I guess I am missing something here..

I guess someday we have to make a Wiki for Clib2 :)

Sinan - AmigaOS4 Beta-Tester
- AmigaOne X5000
- AmigaOne A1222
- Sam460ex
Go to top
Re: How to create clib2 versions of newlib libraries
Home away from home
Home away from home


See User information
@Sinan
So maybe those CMAKE_CXX_FLAGS and CMAKE_C_FLAGS didn't taken into account by main CMakeFile.txt.

What i usually do to be sure that all correct , is calling cmake command, it generate all the stuff, then, simple go to your "build" directory you created, and do search there for filename "flags.make". IT usually will be in the build/CMAkeFiles/name_of_your_app.dir/

There you can check what C_FLAGS and CXX_FLAGS have, and so add -mcrt=clib2 there if there none after you call your cmake command.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: How to create clib2 versions of newlib libraries
Not too shy to talk
Not too shy to talk


See User information
@kas1e

-mcrt=clib2 is there, so CMake works.

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.23

# compile C with /usr/local/amiga/bin/ppc-amigaos-gcc
C_DEFINES 

C_INCLUDES = -I/amiga/develop/freealut/include -I/usr/local/amiga/ppc-amigaos/SDK/Local/clib2/include/AL -I/amiga/develop/freealut/build

C_FLAGS 
= -mcrt=clib2 -finline-functions -ffast-math -fomit-frame-pointer -O3 -DNDEBUG

# Custom flags: CMakeFiles/test_fileloader.dir/test_suite/test_fileloader.c.obj_FLAGS = -Wno-deprecated-declarations

Sinan - AmigaOS4 Beta-Tester
- AmigaOne X5000
- AmigaOne A1222
- Sam460ex
Go to top
Re: How to create clib2 versions of newlib libraries
Just popping in
Just popping in


See User information
@SinanSam460

That you get the error with main seems to indicate a problem with linking, either missing some link libraries or a error in the parameters to ld.

Go to top
Re: How to create clib2 versions of newlib libraries
Not too shy to talk
Not too shy to talk


See User information
@trgswe

I found another fork of freealut. It seems to work.

Sinan - AmigaOS4 Beta-Tester
- AmigaOne X5000
- AmigaOne A1222
- Sam460ex
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project