121
Programming / GCC - proper include files and libraries, what's the method?
« on: February 23, 2018, 03:24:12 am »
Alright..another installment on my "continuing mission to boldly go where with OS/2 coding where I have not gone before"...LOL, this time all about the CORRECT include files!!!
So I have the following on my machine (things that are specific to GCC):
1) RPM packages for:
- gcc.pentium4 4.9.2.1-3.oc00 installed
- libgcc-fwd.pentium4 4.9.2.1-3.oc00 installed
- libgcc1.pentium4 4.9.2.1-3.oc00 installed
- pthread.i686 20151229-21.oc00 installed
- pthread-devel.i686 20151229-21.oc00 installed
- pthread-legacy.i686 20151229-21.oc00 installed
2) OS/2 Warp Toolkit
3) IBMCPP 3.6.5
All of the above have their own include files. So given that I'm trying to learn how GCC itself is structured and what it actually uses on the local machine, I rule out #2 & #3 (gcc session has no visibility to these) I am struggling to understand why the very same include file (there are multiples) occur in several places, take stdio.h as an example.
Just in the RPM based \usr\ tree I find the following:
...what the heck? So why these multiple occurencies?
Also, I note that as RPM installed the pthread.i686 package (to support the -pthread gcc option) it put the pthread.h into \usr\include.
So that is Q1, the second issue might be related to this, not sure, and is as follows: attempting to compile thread enabled CPU benchmark causes my GCC session to fail with the following:
...but since 'gcc -c' alone (so compile only) works that means it's the linker that's failing and most likely because the pthread libarary is missing?
That should not be the case since:
...clearly shows pthread.a and inspecting it I find the _pthread_create/join functions there:
So what am I missing?
So I have the following on my machine (things that are specific to GCC):
1) RPM packages for:
- gcc.pentium4 4.9.2.1-3.oc00 installed
- libgcc-fwd.pentium4 4.9.2.1-3.oc00 installed
- libgcc1.pentium4 4.9.2.1-3.oc00 installed
- pthread.i686 20151229-21.oc00 installed
- pthread-devel.i686 20151229-21.oc00 installed
- pthread-legacy.i686 20151229-21.oc00 installed
2) OS/2 Warp Toolkit
3) IBMCPP 3.6.5
All of the above have their own include files. So given that I'm trying to learn how GCC itself is structured and what it actually uses on the local machine, I rule out #2 & #3 (gcc session has no visibility to these) I am struggling to understand why the very same include file (there are multiples) occur in several places, take stdio.h as an example.
Just in the RPM based \usr\ tree I find the following:
Code: [Select]
[G:\usr]dir stdio.h /s
Directory of G:\usr\include
10-26-14 2:17p 19624 124 stdio.h
1 file(s) 19624 bytes used
Directory of G:\usr\include\c++\4.9.2\tr1
2-01-15 2:07p 1209 124 stdio.h
1 file(s) 1209 bytes used
Directory of G:\usr\lib\gcc\i386-pc-os2-emx\4.9.2\include\ssp
2-01-15 2:08p 3473 124 stdio.h
1 file(s) 3473 bytes used
Directory of G:\usr\lib\gcc\i386-pc-os2-emx\4.9.2\include-fixed
2-01-15 12:34p 20124 124 stdio.h
1 file(s) 20124 bytes used
Total files listed:
4 file(s) 44430 bytes used
4100499 K bytes free
...what the heck? So why these multiple occurencies?
Also, I note that as RPM installed the pthread.i686 package (to support the -pthread gcc option) it put the pthread.h into \usr\include.
So that is Q1, the second issue might be related to this, not sure, and is as follows: attempting to compile thread enabled CPU benchmark causes my GCC session to fail with the following:
Code: [Select]
COLLECT_GCC=gcc
Target: i386-pc-os2-emx
Configured with: ../configure --prefix=/@unixroot/usr --with-sysroot=/@unixroot --enable-shared --enable-languages=c,c++ --enable-frame-pointer --with-gnu-as --disable-bootstrap --disable-multilib --disable-libstdcxx-pch --enable-threads
Thread model: os2
gcc version 4.9.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'CPUbench.exe' '-mtune=i386' '-march=i386'
G:/usr/bin/../libexec/gcc/i386-pc-os2-emx/4.9.2/cc1 -quiet -v -iprefix G:/usr/bin/../lib/gcc/i386-pc-os2-emx/4.9.2/ cpubenchmark.c -quiet -dumpbase cpubenchmark.c -mtune=i386 -march=i386 -auxbase cpubenchmark -version -o G:\var\tmp/ccGyMGfL.s
GNU C (GCC) version 4.9.2 (i386-pc-os2-emx)
compiled by GNU C version 4.7.3, GMP version 5.0.2, MPFR version 3.1.0,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory "G:/usr/bin/../lib/gcc/i386-pc-os2-emx/4.9.2/../../../../i386-pc-os2-emx/include"
ignoring nonexistent directory "/@unixroot/usr/local/include"
ignoring nonexistent directory "G:/usr/lib/gcc/../../lib/gcc/i386-pc-os2-emx/4.9.2/../../../../i386-pc-os2-emx/include"
#include "..." search starts here:
#include <...> search starts here:
G:/usr/bin/../lib/gcc/i386-pc-os2-emx/4.9.2/include
G:/usr/bin/../lib/gcc/i386-pc-os2-emx/4.9.2/include-fixed
G:/usr/lib/gcc/../../lib/gcc/i386-pc-os2-emx/4.9.2/include
G:/usr/lib/gcc/../../lib/gcc/i386-pc-os2-emx/4.9.2/include-fixed
/@unixroot/usr/include
End of search list.
GNU C (GCC) version 4.9.2 (i386-pc-os2-emx)
compiled by GNU C version 4.7.3, GMP version 5.0.2, MPFR version 3.1.0,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 40cb22df062740f747e010b72b1ced6d
COLLECT_GCC_OPTIONS='-v' '-o' 'CPUbench.exe' '-mtune=i386' '-march=i386' as -v --traditional-format -o G:\var\tmp/ccWtYHda.o G:\var\tmp/ccGyMGfL.s
GNU assembler version 2.27 (i386-pc-os2-emx) using BFD version (GNU Binutils) 2.
27
COMPILER_PATH=G:/usr/bin/../libexec/gcc/i386-pc-os2-emx/4.9.2/;G:/usr/bin/../libexec/gcc/;G:/usr/bin/../lib/gcc/i386-pc-os2-emx/4.9.2/../../../../i386-pc-os2-emx/bin/
LIBRARY_PATH=G:/usr/bin/../lib/gcc/i386-pc-os2-emx/4.9.2/;G:/usr/bin/../lib/gcc/;G:/usr/bin/../lib/gcc/i386-pc-os2-emx/4.9.2/../../../;/@unixroot/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'CPUbench.exe' '-mtune=i386' '-march=i386'
ld.exe -o CPUbench.exe G:/usr/bin/../lib/gcc/i386-pc-os2-emx/4.9.2/../../../crt0.o -LG:/usr/bin/../lib/gcc/i386-pc-os2-emx/4.9.2 -LG:/usr/bin/../lib/gcc -LG:/usr/bin/../lib/gcc/i386-pc-os2-emx/4.9.2/../../.. -L/@unixroot/usr/lib G:\var\tmp/ccWtYHda.o -lgcc_so_d -lc_alias -lc_dll -los2 -lgcc_so_d -lc_alias -lc_dll -los
2 -lgcc_so_d -lc_alias -lc_dll -los2 -lgcc_so_d -lc_alias -lc_dll -los2
G:\var\tmp/ccWtYHda.o: Undefined symbol _pthread_create referenced from text segment
G:\var\tmp/ccWtYHda.o: Undefined symbol _pthread_join referenced from text segment
G:\var\tmp/ccWtYHda.o: Undefined symbol _pthread_create referenced from text segment
G:\var\tmp/ccWtYHda.o: Undefined symbol _pthread_join referenced from text segment
...but since 'gcc -c' alone (so compile only) works that means it's the linker that's failing and most likely because the pthread libarary is missing?
That should not be the case since:
Code: [Select]
Directory of G:\usr\lib
12-29-15 9:06a 12424 124 pthread.a
12-29-15 9:06a 4052 124 pthread.dll
12-29-15 9:06a 299570 124 pthread_g.a
12-29-15 9:06a 301982 124 pthread_s.a
4 file(s) 618028 bytes used
...clearly shows pthread.a and inspecting it I find the _pthread_create/join functions there:
Code: [Select]
IMPORT#37#58c81:
00000000 e _pthread_create
00000000 E _pthread_create=pthr01._pthread_create
...
IMPORT#33#458c8:
00000000 e _pthread_join
00000000 E _pthread_join=pthr01._pthread_join
So what am I missing?