Free Downloads, Community Forum,
FAQs and Developer Resources


Make /Tools Your Home | Link to us

Today's posts | Posts since last visit | Most Active Topics

All Forums Register Login Search Subscriptions My Profile Inbox
Tool Warehouse FAQs Resources Help Member List Address Book Logout

mixed mode compilation using gcc on R2

 
Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [SFU / Interix / SUA Technology] >> Windows Server 2003 R2 SUA >> mixed mode compilation using gcc on R2 Page: [1]
Login
Message << Older Topic   Newer Topic >>
mixed mode compilation using gcc on R2 - Mar. 13, '06, 5:20:43 AM   
hrachh

 

Posts: 3
Joined: Feb. 12, '06,
Status: offline
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
Post #: 1
RE: mixed mode compilation using gcc on R2 - Mar. 13, '06, 9:09:13 AM   
jerker_back

 

Posts: 68
Joined: Jul. 7, '05,
From: Sweden
Status: offline
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

(in reply to hrachh)
Post #: 2
RE: mixed mode compilation using gcc on R2 - Mar. 14, '06, 7:37:54 AM   
hrachh

 

Posts: 3
Joined: Feb. 12, '06,
Status: offline
I tried but its not working.

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

(in reply to hrachh)
Post #: 3
RE: mixed mode compilation using gcc on R2 - Mar. 15, '06, 9:46:11 AM   
breiter

 

Posts: 343
Joined: Jun. 14, '04,
From: Washington, DC
Status: offline
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.

(in reply to hrachh)
Post #: 4
RE: mixed mode compilation using gcc on R2 - Mar. 15, '06, 12:13:29 PM   
Rodney

 

Posts: 3695
Joined: Jul. 9, '02,
From: /Tools lab
Status: online
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?

(in reply to breiter)
Post #: 5
RE: mixed mode compilation using gcc on R2 - Mar. 16, '06, 8:17:39 AM   
jerker_back

 

Posts: 68
Joined: Jul. 7, '05,
From: Sweden
Status: offline
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.

(in reply to Rodney)
Post #: 6
RE: mixed mode compilation using gcc on R2 - Mar. 16, '06, 10:42:21 AM   
jerker_back

 

Posts: 68
Joined: Jul. 7, '05,
From: Sweden
Status: offline
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

(in reply to jerker_back)
Post #: 7
RE: mixed mode compilation using gcc on R2 - Mar. 16, '06, 10:59:17 AM   
Rodney

 

Posts: 3695
Joined: Jul. 9, '02,
From: /Tools lab
Status: online
> 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.

(in reply to jerker_back)
Post #: 8
RE: mixed mode compilation using gcc on R2 - Mar. 16, '06, 11:17:46 AM   
breiter

 

Posts: 343
Joined: Jun. 14, '04,
From: Washington, DC
Status: offline
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?

(in reply to Rodney)
Post #: 9
RE: mixed mode compilation using gcc on R2 - Mar. 16, '06, 12:50:01 PM   
Rodney

 

Posts: 3695
Joined: Jul. 9, '02,
From: /Tools lab
Status: online
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.

(in reply to breiter)
Post #: 10
RE: mixed mode compilation using gcc on R2 - Mar. 16, '06, 1:37:45 PM   
jerker_back

 

Posts: 68
Joined: Jul. 7, '05,
From: Sweden
Status: offline
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.

(in reply to Rodney)
Post #: 11
RE: mixed mode compilation using gcc on R2 - Mar. 16, '06, 2:25:01 PM   
Rodney

 

Posts: 3695
Joined: Jul. 9, '02,
From: /Tools lab
Status: online
> 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.

(in reply to jerker_back)
Post #: 12
RE: mixed mode compilation using gcc on R2 - Apr. 22, '06, 8:57:28 AM   
hrachh

 

Posts: 3
Joined: Feb. 12, '06,
Status: offline
mixed mode compilation worked with gcc on SUA.

The key is that SUA only supports Visual Studio 2005 supplied SDK,so copy all the sql* header files of VS 2005 to R2 SUA.

(in reply to Rodney)
Post #: 13
RE: mixed mode compilation using gcc on R2 - Apr. 23, '06, 7:04:45 AM   
jerker_back

 

Posts: 68
Joined: Jul. 7, '05,
From: Sweden
Status: offline
quote:

mixed mode compilation worked with gcc on SUA

Interesting - SUA gcc can then produce WIN32 binaries.
Furthermore, it can apparently understand the windows export libraries.
Did you try the minGW/CygWin gcc?
quote:

The key is that SUA only supports Visual Studio 2005 supplied SDK,so copy all the sql* header files of VS 2005 to R2 SUA

Was it not the case in the beginning?

The headers and libs are the same in Windows 2003 SP1 platform SDK, Windows 2003 SP1 DDK (the overlapped ones) and Visual Studio 2005 platform SDK. Only minor changes (less then 10 files) in the new Windows R2 platform SDK. This is true only if you trust windiff of course, otherwise one have to stick with the entire build trees for each tool. They are all built with the 7.1/13.10 MS development toolset and I suspect using the MS tool build.exe.

(in reply to hrachh)
Post #: 14
Page:   [1]
All Forums >> [SFU / Interix / SUA Technology] >> Windows Server 2003 R2 SUA >> mixed mode compilation using gcc on R2 Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Search All Forums -

Advanced search


SPONSORS



Forum Software © ASPPlayground.NET Advanced Edition 2.5 ANSI

0.063