- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Linking sql$mod with C
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2005 08:38 PM
12-19-2005 08:38 PM
Linking sql$mod with C
Things works perfect with Pascal but I'm not able to do the same in C...
I have a SQL Module file wich i compile with:
$SYS$SYSTEM:SQL$MOD71/ANSI_PARAMETER sql$test.sqlmod
sql$test.sqlmod (extract):
MODULE SQL$TEST
LANGUAGE C
AUTHORIZATION SQL_SAMPLLE
PARAMETER COLONS
PROCEDURE sql$commit
sqlcode;
commit;
and an C file wich I compile with:
cxx test.c
test.c (extract):
#include
long sqlcode;
void sql$commit( long *sqlcode );
void main() {
sql$commit( &sqlcode );
printf( "%ld\n", sqlcode );
}
Then I link both with:
cxxlink test,sql$test,SYS$COMMON:[SYSLIB]sql$user71/lib
And I got the following error:
%LINK-W-USEUNDEF, undefined symbol void sql$commit(long *) referenced
in psect $LINK$ offset %X00000060
in module TEST file TEST.OBJ;1
Thanx in advance for any help.
François
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2005 09:58 PM
12-19-2005 09:58 PM
Re: Linking sql$mod with C
Purely Personal Opinion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2005 10:10 PM
12-19-2005 10:10 PM
Re: Linking sql$mod with C
%LINK-W-USEUNDEF, undefined symbol CXXL$V60_MAIN_DISPATCH referenced
in psect $LINK$ offset %X00000020
in module TEST file TEST.OBJ;15
%LINK-W-USEUNDEF, undefined symbol SQL$COMMIT__XPL referenced
in psect $LINK$ offset %X00000060
in module TEST file TEST.OBJ;15
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2005 12:03 AM
12-20-2005 12:03 AM
Re: Linking sql$mod with C
And if you link explicitly with SYS$SHARE:SQL$SHR.EXE (or SYS$SHARE:SQL$SHR71.EXE) ?
Regards,
Kris (aka Qkcl)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2005 12:25 AM
12-20-2005 12:25 AM
Re: Linking sql$mod with C
the following link statement produces many errors:
cxxlink test,sql$test,sql$user/lib,SQL$SHR/shareable
%LINK-W-RECTYP, file SYS$COMMON:[SYSLIB]SQL$SHR71.EXE;1 record 1 is illegal (3.)
and so on...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2005 02:33 AM
12-20-2005 02:33 AM
Re: Linking sql$mod with C
It just struck me. The initial warning reports about sql$commit in lowercase.
Could you change your "test.c" file so that SQL$COMMIT is in uppercase.
I think that it has something to do with the C++ compiler preserving the case.
Regards,
Kris (aka Qkcl)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2005 02:51 AM
12-20-2005 02:51 AM
Re: Linking sql$mod with C
cxx test.c
and
cxxlink test,sql$test,SYS$COMMON:[SYSLIB]sql$user71/lib
Means that you use C++ not C. C++ encode names and you have to use extern "C" to avoid this. Try with:
#include
long sqlcode;
extern "C" {
void sql$commit( long *sqlcode );
}
void main() {
sql$commit( &sqlcode );
printf( "%ld\n", sqlcode );
}
to avoid C++ name managling.
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2005 02:51 AM
12-20-2005 02:51 AM
Re: Linking sql$mod with C
(sorry for the misspelling in the previous post)
Changed everything in uppercase with no success....
tried before with the /NAMES=AS_IS compiler switch. No success as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2005 02:57 AM
12-20-2005 02:57 AM
Re: Linking sql$mod with C
After some investigation...
Please change the declaration of sql$common in test.c thus:
#ifdef __cplusplus
extern "C" {
#endif
void sql$commit( long *sqlcode );
#ifdef __cplusplus
}
#endif
That worked for me.
Regards,
Kris (aka Qkcl)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2005 10:06 PM
12-20-2005 10:06 PM
Re: Linking sql$mod with C
You put me on the way....
I had to change 3 things (2 of them you suggested)
1. Put everything in uppercase to avoid mismatch
2. Define the C like declaration because of using C++ compiler/linker
3. Replace the '$' sign in the external function with '_'
My program now looks like below and does well.
test.c
#include
long sqlcode;
#ifdef __cplusplus
extern "C" {
#endif
void SQL_COMMIT( long *sqlcode );
#ifdef __cplusplus
}
#endif
void main()
{
SQL_COMMIT( &sqlcode );
printf( "return code = >%ld<\n", sqlcode );
}
sql$test.sqlmod
MODULE SQL_HP
LANGUAGE C
AUTHORIZATION SQL_USER
PARAMETER COLONS
PROCEDURE SQL_COMMIT
SQLCODE;
COMMIT;
$ cxx test.c
$ sqlmod sql$test.sqlmod
$ cxxlink test,sql$test,sql$user/lib
$ run test
Many thanks for you help and your quick answers.
Best Regards
François