mixed mode compilation using gcc on R2 (Full Version)

All Forums >> [SFU / Interix / SUA Technology] >> Windows Server 2003 R2 SUA



Message


hrachh -> mixed mode compilation using gcc on R2 (Mar. 13, '06, 5:20:43 AM)

Hi,

I am trying to compile a small program on R2 SUA using gcc and getting linking error though same program i am able to compile with c89.

******************c89*********************************
c89 -D WIN32 –I “/dev/fs/C/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/include” –N nostdc –R sample.c “/dev/fs/C/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Lib/odbc32.lib”

**********************GCC****************************
gcc –I “/dev/fs/C/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/include” -R sample.c “/dev/fs/C/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Lib/odbc32.lib”

/tmp/ccQCguZw.o(.text+0x48):sample.c: undefined reference to `_SQLGetDiagRec'
/tmp/ccQCguZw.o(.text+0x9e):sample.c: undefined reference to `_SQLAllocHandle'
/tmp/ccQCguZw.o(.text+0xd5):sample.c: undefined reference to `_SQLSetEnvAttr'
/tmp/ccQCguZw.o(.text+0x10b):sample.c: undefined reference to `_SQLAllocHandle'
/tmp/ccQCguZw.o(.text+0x13f):sample.c: undefined reference to `_SQLSetConnectAtt
r'
/tmp/ccQCguZw.o(.text+0x179):sample.c: undefined reference to `_SQLSetConnectAtt
r'
/tmp/ccQCguZw.o(.text+0x1bc):sample.c: undefined reference to `_SQLConnect'
/tmp/ccQCguZw.o(.text+0x208):sample.c: undefined reference to `_SQLFreeHandle'
/tmp/ccQCguZw.o(.text+0x21e):sample.c: undefined reference to `_SQLFreeHandle'
/tmp/ccQCguZw.o(.text+0x265):sample.c: undefined reference to `_SQLAllocHandle'
/tmp/ccQCguZw.o(.text+0x29a):sample.c: undefined reference to `_SQLSetStmtAttr'
/tmp/ccQCguZw.o(.text+0x2e4):sample.c: undefined reference to `_SQLSetStmtAttr'
/tmp/ccQCguZw.o(.text+0x32e):sample.c: undefined reference to `_SQLSetStmtAttr'
/tmp/ccQCguZw.o(.text+0x353):sample.c: undefined reference to `_SQLSetStmtAttr'
/tmp/ccQCguZw.o(.text+0x37a):sample.c: undefined reference to `_SQLSetStmtAttr'
/tmp/ccQCguZw.o(.text+0x3a3):sample.c: undefined reference to `_SQLSetCursorName
'
/tmp/ccQCguZw.o(.text+0x3d3):sample.c: undefined reference to `_SQLBindCol'
/tmp/ccQCguZw.o(.text+0x403):sample.c: undefined reference to `_SQLBindCol'
/tmp/ccQCguZw.o(.text+0x42c):sample.c: undefined reference to `_SQLExecDirect'
/tmp/ccQCguZw.o(.text+0x441):sample.c: undefined reference to `_SQLExecDirect'
/tmp/ccQCguZw.o(.text+0x4b9):sample.c: undefined reference to `_SQLExecDirect'
/tmp/ccQCguZw.o(.text+0x4ec):sample.c: undefined reference to `_SQLExecDirect'
/tmp/ccQCguZw.o(.text+0x510):sample.c: undefined reference to `_SQLFetchScroll'
/tmp/ccQCguZw.o(.text+0x568):sample.c: undefined reference to `_SQLCloseCursor'
collect2: ld returned 1 exit status

************************************************

Can anyone help me on "how to compile program using gcc?".

--Hemant




jerker_back -> RE: mixed mode compilation using gcc on R2 (Mar. 13, '06, 9:09:13 AM)

Hello Hemant

Well, I'm absolutly no gcc guru but try:
gcc –I/dev/fs/<whatever>/include -l/dev/fs/<whatever>/lib/odbc32.lib sample.c 

That's a l (a small L), no quots or spaces

or even better then listen to my guesses: GCC options

What's wrong with c89?

regards Jerker




hrachh -> RE: mixed mode compilation using gcc on R2 (Mar. 14, '06, 7:37:54 AM)

I tried but its not working.

c89 is working but we want to stick with gnu standards.




breiter -> RE: mixed mode compilation using gcc on R2 (Mar. 15, '06, 9:46:11 AM)

It was my understanding that you have to use cl.exe from Visual Studio 2005 via the /bin/cc script to compile mixed mode binaries and that they have to be statically linked.




Rodney -> RE: mixed mode compilation using gcc on R2 (Mar. 15, '06, 12:13:29 PM)

The '-R' (mixed mode) is supposed to be valid for c89/cc and gcc.

The one thing that MS will say (because they have said it already) is that today the
mixed mode is strictly supported only with the Oracle libraries; after that it's freewheeling.

The question is: how to get gcc to look at this library?




jerker_back -> RE: mixed mode compilation using gcc on R2 (Mar. 16, '06, 8:17:39 AM)

Sorry if I sound rude now but...
GNU standards? There's no GNU in SUA besides gcc what I know of
Besides, the ODBC library is definitly not GNU.
This said - there is absolutly nothing wrong with GNU.
According to the path in your example, you have Visual Studio 2005 - why not use it?
The libraries in the Win32 platform SDK is produced with a 7.1/13.10 MS toolset and there should be no problem to compile and link with a toolset > 6.0
You can probably do it with a Borland, Intel or minGW toolset also.
It's a simple Win32 console application linked to the SUA libraries.




jerker_back -> RE: mixed mode compilation using gcc on R2 (Mar. 16, '06, 10:42:21 AM)

Consider this:
// mixedmodetest.cpp
// compile with any win32 compiler
// compileroptions: /O2 /X /Zl /I%SystemRoot%\SUA\usr\include
// linkeroptions:   /nodefaultlib /libpath:%SystemRoot%\SUA\usr\lib /subsystem:console 
//                  /entry:__MixedModeProcessStartup libpsxdll.a libcsafe.a safecrt0.o
#include <stdio.h>
#include <sys/utsname.h>

extern "C"
int __cdecl main()
{
    utsname OSinfo = {0};
    if(uname(&OSinfo) < 0) return -1;
    const char szFormat[] = "System = %s\nNode = %s\nRelease = %s\nVersion = %s\n";
    printf (szFormat, OSinfo.sysname, OSinfo.nodename, OSinfo.release, OSinfo.version);

    return 0;
}

Using the Intel compiler, the commandline could look like this:

set cloptions=/O2 /X /Zl /I%SystemRoot%\SUA\usr\include
set linkoptions=/nodefaultlib /libpath:%SystemRoot%\SUA\usr\lib /subsystem:console \
                /entry:__MixedModeProcessStartup libpsxdll.a libcsafe.a safecrt0.o
icl.exe %cloptions% mixedmodetest.cpp /link %linkoptions% libircmt.lib

It works for me in SUA




Rodney -> RE: mixed mode compilation using gcc on R2 (Mar. 16, '06, 10:59:17 AM)

> GNU standards? There's no GNU in SUA besides gcc what I know of

No one wrote anything about a "standard".
The '-R' option AFAIK was chosen simply because it wasn't already used.
You are correct that there is no GNU in SUA (the subsystem).
Besides gcc there are a couple of other utilities, but that's all known.

> This said - there is absolutly nothing wrong with GNU.

Well, gcc has been modified by MS for mixed-mode. There are likely limits
but hrachh is trying to get it to work for himself with certain criteria.

> It's a simple Win32 console application linked to the SUA libraries.

Yes and no. The binary is identified as a Win32 program to work with CSRSS
(the Win32 subsystem). It is also linked to a special library to make calls
to the Interix subsystem (these are not the same as what an Interix process
would call). Just FYI.




breiter -> RE: mixed mode compilation using gcc on R2 (Mar. 16, '06, 11:17:46 AM)

quote:

It is also linked to a special library to make calls
to the Interix subsystem (these are not the same as what an Interix process would call).

Is the conduit for this cross-subystem communcation the new PSXDRV.SYS kernel driver?




Rodney -> RE: mixed mode compilation using gcc on R2 (Mar. 16, '06, 12:50:01 PM)

No, it's a DLL. There's a special file for linking.
Communication between a process and a subsystem is done by LPC's (messages).
This is true for all processes and subsystems, also for subsystem to subsystem communication.

The mixed-mode application is in a different context. That context being talking
to two very different environment subsystems at the same time. So the same DLL
doing the communication cannot be used otherwise conflicts would happen too easily.
Conflicts can still happen, but that can be expected with two paradigms at some point.




jerker_back -> RE: mixed mode compilation using gcc on R2 (Mar. 16, '06, 1:37:45 PM)

quote:

The mixed-mode application is in a different context. That context being talking
to two very different environment subsystems at the same time. So the same DLL
doing the communication cannot be used otherwise conflicts would happen too easily.
Conflicts can still happen, but that can be expected with two paradigms at some point.

No, I don't get it. What do you mean? I thought the mixed-mode application is running in the WIN32 subsystem, but with a special ability to make native calls into the posix subsystem. You mean it is running 2 threads, one for each subsystem and using the special DLL for interprocess communication? At least in the StartUp process it must be using the WIN32 subsystem, or?

Anyway in practice, my point was that any win32 compiler should be able to compile a mixed-mode app as long as they specify the right entrypoint function -__MixedModeProcessStartup. It not clear however what libraries we can use. Is it OK to use the Win32 MS C runtime (as long as the Interix LIBC is not used)? What about wide char (_UNICODE flag)?

quote:

Well, gcc has been modified by MS for mixed-mode.

So this gcc can produce Win32 binaries?
Here's a field with many questions.




Rodney -> RE: mixed mode compilation using gcc on R2 (Mar. 16, '06, 2:25:01 PM)

> No, I don't get it. What do you mean?

Just that a different DLL is used for LPC's when the binary is "mixed-mode/Win32" than with Interix binaries.

> Anyway in practice, my point was that any win32 compiler should be able to compile a mixed-mode app as long as they specify the right entrypoint function

Almost yes. Intel, for example, can make the same changes to their compiler.
You have to be careful to use the special LIBC DLL before Interix's libc and certainly before MSVC's CRT.

> What about wide char (_UNICODE flag)?

What about it?

> So this gcc can produce Win32 binaries?

It's just a case of setting the right bit in the binary to identify which subsystem
is responsible for the binary's startup. Of course the linking needs to be done right.




Page: [1]



Forum Software © ASPPlayground.NET Advanced Edition 2.5 ANSI

0.047