<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Linking sql$mod with C in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694762#M33181</link>
    <description>Hi Chris,&lt;BR /&gt;&lt;BR /&gt;the following link statement produces many errors:&lt;BR /&gt;cxxlink test,sql$test,sql$user/lib,SQL$SHR/shareable&lt;BR /&gt;&lt;BR /&gt;%LINK-W-RECTYP, file SYS$COMMON:[SYSLIB]SQL$SHR71.EXE;1 record 1 is illegal (3.)&lt;BR /&gt;and so on...</description>
    <pubDate>Tue, 20 Dec 2005 08:25:44 GMT</pubDate>
    <dc:creator>Kaufmann François</dc:creator>
    <dc:date>2005-12-20T08:25:44Z</dc:date>
    <item>
      <title>Linking sql$mod with C</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694758#M33177</link>
      <description>Hi there,&lt;BR /&gt;&lt;BR /&gt;Things works perfect with Pascal but I'm not able to do the same in C...&lt;BR /&gt;&lt;BR /&gt;I have a SQL Module file wich i compile with:&lt;BR /&gt;$SYS$SYSTEM:SQL$MOD71/ANSI_PARAMETER sql$test.sqlmod&lt;BR /&gt;&lt;BR /&gt;sql$test.sqlmod (extract):&lt;BR /&gt;MODULE          SQL$TEST&lt;BR /&gt;LANGUAGE        C&lt;BR /&gt;AUTHORIZATION   SQL_SAMPLLE&lt;BR /&gt;PARAMETER       COLONS&lt;BR /&gt;PROCEDURE sql$commit&lt;BR /&gt;        sqlcode;&lt;BR /&gt;commit;&lt;BR /&gt;&lt;BR /&gt;and an C file wich I compile with:&lt;BR /&gt;cxx test.c&lt;BR /&gt;&lt;BR /&gt;test.c (extract):&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;long sqlcode;&lt;BR /&gt;void sql$commit( long *sqlcode );&lt;BR /&gt;void main() {&lt;BR /&gt;sql$commit( &amp;amp;sqlcode );&lt;BR /&gt;printf( "%ld\n", sqlcode );&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Then I link both with:&lt;BR /&gt;cxxlink test,sql$test,SYS$COMMON:[SYSLIB]sql$user71/lib&lt;BR /&gt;&lt;BR /&gt;And I got the following error:&lt;BR /&gt;%LINK-W-USEUNDEF, undefined symbol void sql$commit(long *) referenced&lt;BR /&gt;        in psect $LINK$ offset %X00000060&lt;BR /&gt;        in module TEST file TEST.OBJ;1&lt;BR /&gt;&lt;BR /&gt;Thanx in advance for any help.&lt;BR /&gt;&lt;BR /&gt;François&lt;BR /&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Tue, 20 Dec 2005 04:38:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694758#M33177</guid>
      <dc:creator>Kaufmann François</dc:creator>
      <dc:date>2005-12-20T04:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: Linking sql$mod with C</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694759#M33178</link>
      <description>What happens when you use LINK instead of cxxlink ?</description>
      <pubDate>Tue, 20 Dec 2005 05:58:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694759#M33178</guid>
      <dc:creator>Ian Miller.</dc:creator>
      <dc:date>2005-12-20T05:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Linking sql$mod with C</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694760#M33179</link>
      <description>Approx the same&lt;BR /&gt;&lt;BR /&gt;%LINK-W-USEUNDEF, undefined symbol CXXL$V60_MAIN_DISPATCH referenced&lt;BR /&gt;        in psect $LINK$ offset %X00000020&lt;BR /&gt;        in module TEST file TEST.OBJ;15&lt;BR /&gt;%LINK-W-USEUNDEF, undefined symbol SQL$COMMIT__XPL referenced&lt;BR /&gt;        in psect $LINK$ offset %X00000060&lt;BR /&gt;        in module TEST file TEST.OBJ;15</description>
      <pubDate>Tue, 20 Dec 2005 06:10:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694760#M33179</guid>
      <dc:creator>Kaufmann François</dc:creator>
      <dc:date>2005-12-20T06:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Linking sql$mod with C</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694761#M33180</link>
      <description>FranÃ§ois,&lt;BR /&gt;And if you link explicitly with SYS$SHARE:SQL$SHR.EXE (or SYS$SHARE:SQL$SHR71.EXE) ?&lt;BR /&gt;Regards,&lt;BR /&gt;Kris (aka Qkcl)</description>
      <pubDate>Tue, 20 Dec 2005 08:03:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694761#M33180</guid>
      <dc:creator>Kris Clippeleyr</dc:creator>
      <dc:date>2005-12-20T08:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Linking sql$mod with C</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694762#M33181</link>
      <description>Hi Chris,&lt;BR /&gt;&lt;BR /&gt;the following link statement produces many errors:&lt;BR /&gt;cxxlink test,sql$test,sql$user/lib,SQL$SHR/shareable&lt;BR /&gt;&lt;BR /&gt;%LINK-W-RECTYP, file SYS$COMMON:[SYSLIB]SQL$SHR71.EXE;1 record 1 is illegal (3.)&lt;BR /&gt;and so on...</description>
      <pubDate>Tue, 20 Dec 2005 08:25:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694762#M33181</guid>
      <dc:creator>Kaufmann François</dc:creator>
      <dc:date>2005-12-20T08:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Linking sql$mod with C</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694763#M33182</link>
      <description>FranÃ§ois,&lt;BR /&gt;It just struck me. The initial warning reports about sql$commit in lowercase.&lt;BR /&gt;Could you change your "test.c" file so that SQL$COMMIT is in uppercase.&lt;BR /&gt;I think that it has something to do with the C++ compiler preserving the case.&lt;BR /&gt;Regards,&lt;BR /&gt;Kris (aka Qkcl)</description>
      <pubDate>Tue, 20 Dec 2005 10:33:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694763#M33182</guid>
      <dc:creator>Kris Clippeleyr</dc:creator>
      <dc:date>2005-12-20T10:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: Linking sql$mod with C</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694764#M33183</link>
      <description>FranÃ§ois,&lt;BR /&gt;&lt;BR /&gt;&lt;QUOTE&gt;&lt;BR /&gt;cxx test.c&lt;BR /&gt;&lt;BR /&gt;and &lt;BR /&gt;&lt;BR /&gt;cxxlink test,sql$test,SYS$COMMON:[SYSLIB]sql$user71/lib&lt;BR /&gt;&lt;/QUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;Means that you use C++ not C. C++ encode names and you have to use extern "C" to avoid this. Try with:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;long sqlcode;&lt;BR /&gt;&lt;BR /&gt;extern "C" {&lt;BR /&gt;void sql$commit( long *sqlcode );&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void main() {&lt;BR /&gt;sql$commit( &amp;amp;sqlcode );&lt;BR /&gt;printf( "%ld\n", sqlcode );&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;to avoid C++ name managling.&lt;BR /&gt;&lt;BR /&gt;Bojan&lt;/STDIO.H&gt;</description>
      <pubDate>Tue, 20 Dec 2005 10:51:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694764#M33183</guid>
      <dc:creator>Bojan Nemec</dc:creator>
      <dc:date>2005-12-20T10:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Linking sql$mod with C</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694765#M33184</link>
      <description>Kris, &lt;BR /&gt;(sorry for the misspelling in the previous post)&lt;BR /&gt;&lt;BR /&gt;Changed everything in uppercase with no success....&lt;BR /&gt;&lt;BR /&gt;tried before with the /NAMES=AS_IS compiler switch. No success as well.</description>
      <pubDate>Tue, 20 Dec 2005 10:51:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694765#M33184</guid>
      <dc:creator>Kaufmann François</dc:creator>
      <dc:date>2005-12-20T10:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Linking sql$mod with C</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694766#M33185</link>
      <description>FranÃ§ois,&lt;BR /&gt;After some investigation...&lt;BR /&gt;Please change the declaration of sql$common in test.c thus:&lt;BR /&gt;&lt;BR /&gt;#ifdef __cplusplus&lt;BR /&gt;extern "C" {&lt;BR /&gt;#endif&lt;BR /&gt;void sql$commit( long *sqlcode );&lt;BR /&gt;#ifdef __cplusplus&lt;BR /&gt;}&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;That worked for me.&lt;BR /&gt;Regards,&lt;BR /&gt;Kris (aka Qkcl)</description>
      <pubDate>Tue, 20 Dec 2005 10:57:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694766#M33185</guid>
      <dc:creator>Kris Clippeleyr</dc:creator>
      <dc:date>2005-12-20T10:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Linking sql$mod with C</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694767#M33186</link>
      <description>Hi Kris,&lt;BR /&gt;&lt;BR /&gt;You put me on the way....&lt;BR /&gt;&lt;BR /&gt;I had to change 3 things (2 of them you suggested)&lt;BR /&gt;1. Put everything in uppercase to avoid mismatch&lt;BR /&gt;2. Define the C like declaration because of using C++ compiler/linker&lt;BR /&gt;3. Replace the '$' sign in the external function with '_'&lt;BR /&gt;&lt;BR /&gt;My program now looks like below and does well.&lt;BR /&gt;test.c&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;&lt;BR /&gt;long    sqlcode;&lt;BR /&gt;&lt;BR /&gt;#ifdef __cplusplus&lt;BR /&gt;extern "C" {&lt;BR /&gt;#endif&lt;BR /&gt;void SQL_COMMIT( long *sqlcode );&lt;BR /&gt;#ifdef __cplusplus&lt;BR /&gt;}&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;void main()&lt;BR /&gt;{&lt;BR /&gt;SQL_COMMIT( &amp;amp;sqlcode );&lt;BR /&gt;printf( "return code = &amp;gt;%ld&amp;lt;\n", sqlcode );&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sql$test.sqlmod&lt;BR /&gt;MODULE          SQL_HP&lt;BR /&gt;LANGUAGE        C&lt;BR /&gt;AUTHORIZATION   SQL_USER&lt;BR /&gt;PARAMETER       COLONS&lt;BR /&gt;&lt;BR /&gt;PROCEDURE SQL_COMMIT&lt;BR /&gt;        SQLCODE;&lt;BR /&gt;COMMIT;&lt;BR /&gt;&lt;BR /&gt;$ cxx test.c&lt;BR /&gt;$ sqlmod sql$test.sqlmod&lt;BR /&gt;$ cxxlink test,sql$test,sql$user/lib&lt;BR /&gt;$ run test&lt;BR /&gt;&lt;BR /&gt;Many thanks for you help and your quick answers.&lt;BR /&gt;&lt;BR /&gt;Best Regards&lt;BR /&gt;FranÃ§ois&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 21 Dec 2005 06:06:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/linking-sql-mod-with-c/m-p/3694767#M33186</guid>
      <dc:creator>Kaufmann François</dc:creator>
      <dc:date>2005-12-21T06:06:24Z</dc:date>
    </item>
  </channel>
</rss>

