Closed krabobmkd closed 7 months ago
Welll , I may have my answer ... but. I've just understood that if you explicitly implement the global lib Base and inited to NULL in the source, it will not be OpenLibrary()-fied before the main... and so I can just do it explicitly as I'm looking for. But then i'm confused , because it would mean there is "2 implementations of the library base linked in the code with the same name" ... usually linkers don't allow that. Is there something specific to "manage the library base pointer if they weren't defined" ... or is it a C/C++ naming issue were 2 names can coexists ? Then other source may use the one or the other Base version. I will experiment with "extern "C" {} "
Let me try to explain it:
struct Library * SomeBase;
Tells the compiler/linker that you want that variable and it's handled as a common symbol.
If someone provides that as a defined variable, it will be linked and used. The libs are searched for undefined/common symbols but not for defined variables.
That's how autoopen works: the linked object file from libstubs.a
provides the defined variable and adds code to open/close the lib.
If no object defines that variable, it is ends up in the bss segment and thus it's also ok.
If you use
struct Library * SomeBase = NULL;
then you define that variable with value. It's no longer a common symbol. It is not resolved by a library.
And If you link two objects defining the same variable, then you'll get a duplicate symbol error.
Hello, I am porting a big c++11 project, and I don't understand the way the linker will automatically do the LoadLibrary() calls for the libs actually used by the code. for each lb I have a #include <proto/thatlib.h> As I understand, if anything use "IntuitionBase", IntuitionBase = OpenLibrary("...") call is made before entering the main, and if the OpenLibrary() call fail, an exit is done and we never enter the main()..
That could be very fine, except that I would specify that my minimal intuition version is 39, and it doesn't seem to have a way for that. I am thinking of just re-doing CloseLibrary()/OpenLibrary to be sure it is 39.
More annoyingly, on the other hand, I want to manage "either cybergraphics or picasso" or neither of those 2 graphical drivers. and that is a problem, because I just can't include any <proto/cybergraphics.h> or just <inline/cybergraphics.h> and test for the presence or not of such driver , it will exit before entering the main, printing: "CyberGfx.library failed to load" , as soon As I refer to CyberGfxBase at any place in the code... (plus: this is tested on a machine that has actually a cybergraphics implementation) So well I'm looking for a way to just use OpenLibrary() and CloseLibrary() explicitly, as you would with dlopen() dlclose() on linux.![image](https://github.com/bebbo/amiga-gcc/assets/62884269/125db72a-0a6a-44be-94a7-ee682f712d79)
My wordy log configured with cmake gives these options: COLLECT_GCC_OPTIONS='-D' 'INLINE=inline' '-D' 'MAMEVERSION=37' '-I' '/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/build-amiga-AmigaGcc-Release' '-I' '/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/amiga' '-I' '/opt/amiga/m68k-amigaos/ndk-include' '-I' '/opt/amiga/m68k-amigaos/include' '-I' '/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/amiga/../../include' '-I' '/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/amiga/../mame037b/src' '-I' '/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/amiga/../../../extrasdk/MUI/include' '-D' 'AMIGA' '-D' 'AMIGA' '-v' '-noixemul' '-funsigned-char' '-ansi' '-mcpu=68060' '-mhard-float' '-ffast-math' '-save-temps' '-std=gnu++11' '-o' 'CMakeFiles/rmame.dir/r2_main.cpp.obj' '-c' '-B' '/opt/amiga/m68k-amigaos/libnix/lib/' /opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/as --traditional-format -m68060 -o CMakeFiles/rmame.dir/r2_main.cpp.obj r2_main.s COMPILER_PATH=/opt/amiga/m68k-amigaos/libnix/lib/:/opt/amiga/libexec/gcc/m68k-amigaos/6.5.0b/:/opt/amiga/libexec/gcc/:/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ LIBRARY_PATH=/opt/amiga/m68k-amigaos/libnix/lib/libm060/:/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/libm060/:/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/lib/libm060/:/opt/amiga/m68k-amigaos/libnix/lib/:/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/:/opt/amiga/lib/gcc/:/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/lib/:/opt/amiga/lib/ COLLECT_GCC_OPTIONS='-D' 'INLINE=inline' '-D' 'MAMEVERSION=37' '-I' '/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/build-amiga-AmigaGcc-Release' '-I' '/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/amiga' '-I' '/opt/amiga/m68k-amigaos/ndk-include' '-I' '/opt/amiga/m68k-amigaos/include' '-I' '/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/amiga/../../include' '-I' '/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/amiga/../mame037b/src' '-I' '/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/amiga/../../../extrasdk/MUI/include' '-D' 'AMIGA' '-D' 'AMIGA' '-v' '-noixemul' '-funsigned-char' '-ansi' '-mcpu=68060' '-mhard-float' '-ffast-math' '-save-temps' '-std=gnu++11' '-o' 'CMakeFiles/rmame.dir/r2_main.cpp.obj' '-c' '-B' '/opt/amiga/m68k-amigaos/libnix/lib/' [100%] Linking CXX executable rmame Using built-in specs. COLLECT_GCC=/opt/amiga/bin/m68k-amigaos-g++ COLLECT_LTO_WRAPPER=/opt/amiga/libexec/gcc/m68k-amigaos/6.5.0b/lto-wrapper Target: m68k-amigaos Configured with: /home/krabob/Code/gcc-amiga/amiga-gcc/projects/gcc/configure --prefix=/opt/amiga --target=m68k-amigaos --enable-languages=c,c++,objc --enable-version-specific-runtime-libs --disable-libssp --disable-nls --with-headers=/home/krabob/Code/gcc-amiga/amiga-gcc/projects/newlib-cygwin/newlib/libc/sys/amigaos/include/ --disable-shared --enable-threads=no --with-stage1-ldflags='-dynamic-libgcc -dynamic-libstdc++' --with-boot-ldflags='-dynamic-libgcc -dynamic-libstdc++' : (reconfigured) /home/krabob/Code/gcc-amiga/amiga-gcc/projects/gcc/configure --prefix=/opt/amiga --target=m68k-amigaos --enable-languages=c,c++,objc --enable-version-specific-runtime-libs --disable-libssp --disable-nls --with-headers=/home/krabob/Code/gcc-amiga/amiga-gcc/projects/newlib-cygwin/newlib/libc/sys/amigaos/include/ --disable-shared --enable-threads=no --with-stage1-ldflags='-dynamic-libgcc -dynamic-libstdc++' --with-boot-ldflags='-dynamic-libgcc -dynamic-libstdc++' Thread model: single gcc version 6.5.0b 221001103737 (GCC) COMPILER_PATH=/opt/amiga/m68k-amigaos/libnix/lib/:/opt/amiga/libexec/gcc/m68k-amigaos/6.5.0b/:/opt/amiga/libexec/gcc/:/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/bin/ LIBRARY_PATH=/opt/amiga/m68k-amigaos/libnix/lib/:/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/:/opt/amiga/lib/gcc/:/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b/../../../../m68k-amigaos/lib/:/opt/amiga/lib/ COLLECT_GCC_OPTIONS='-D' 'AMIGA' '-D' 'AMIGA' '-v' '-noixemul' '-funsigned-char' '-ansi' '-v' '-o' 'rmame' '-L/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/amiga/../../lib' '-lm' '-mcpu=68000' '-B' '/opt/amiga/m68k-amigaos/libnix/lib/' /opt/amiga/libexec/gcc/m68k-amigaos/6.5.0b/collect2 --sysroot=/opt/amiga -L/opt/amiga/lib -L/opt/amiga/m68k-amigaos/libnix/lib -o rmame /opt/amiga/m68k-amigaos/libnix/lib/ncrt0.o -L/home/krabob/Code/Amiga/amigagcc6ports/mame-triumph/src/amiga/../../lib -L/opt/amiga/m68k-amigaos/libnix/lib -L/opt/amiga/lib/gcc/m68k-amigaos/6.5.0b -L/opt/amiga/lib/gcc -L/opt/amiga/lib @/tmp/cc961xgx -( -lnix20 -lnixmain -lnix -lstubs -lamiga -lgcc -lm -lm -) /opt/amiga/m68k-amigaos/libnix/lib/xcrt0.o [100%] Built target rmame