GemBuilder for C compilation on 3.6.1

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GemBuilder for C compilation on 3.6.1

GLASS mailing list
Hi all,

I am trying to compile C code that calls GemBuilder for C functions.
I take inspiration from
https://downloads.gemtalksystems.com/docs/GemStone64/3.6.x/GS64-GemBuilderforC-3.6.pdf 
sections 5.2 and 5.3.

I am doing this on Ubuntu 20.04, using g++ 9.3.0 all of which are
supported according to the above doc.

I also have installed GemStone64Bit3.6.1-x86_64.Linux

I have a simplified test program that just calls a simple function from
libgcits. I can compile and link, but when I run the resultant program
it segfaults when I callthe Gci function. I have to confess that I
haven't touched C in 20 years, so I am probably doing stupid things. (I
had this working with GemStone 3.4.1)

Here is my program (test.c):

#include <stdio.h>
#include <gcits.hf>

int main() {
   const char *unencrypted_password = "abcde";
   char *out_buff;
   char *encrypted_password;
   int encrypted_char;
   unsigned int out_buff_size = 1000;
   out_buff = (char *)malloc(out_buff_size * sizeof(char));
   GciTsEncrypt(unencrypted_password, out_buff, out_buff_size);
   free(out_buff);
   return 0;
}

I build it using this makefile:

COMPILE_FLAGS=-fmessage-length=0 -fcheck-new -O3 -ggdb -m64 -pipe \
               -D_REENTRANT -D_GNU_SOURCE -pthread -fPIC \
               -fno-strict-aliasing -fno-exceptions -x c++

LINK_FLAGS=-m64 -Wl,-Bdynamic,--no-as-needed -lpthread -Wl,--as-needed \
            -lcrypt -ldl -lc -lm -lrt -Wl,-traditional -Wl,-z,lazy

all:
        g++ -I${GEMSTONE}/include ${COMPILE_FLAGS} -c test.c -o test.o
        g++ -L${GEMSTONE}/lib -lgcits-3.6.1-64 ${LINK_FLAGS} test.o -o test


The options above are taken from 5.3 of the doc, except that I link
gcits-3.6.1-64 library directly instead of using the run time loading as
is explained earlier in the doc.

What am I missing here?

Regards
Iwan

--


_______________________________________________
Glass mailing list
[hidden email]
https://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: GemBuilder for C compilation on 3.6.1

GLASS mailing list
Can you show us the C stack trace at the point of the SIGSEGV?

------------------------------------------------------------------------
Bill Erickson
GemTalk Systems Engineering
15220 NW Greenbrier Parkway #240, Beaverton OR 97006
------------------------------------------------------------------------


On Sun, Jun 20, 2021 at 2:03 AM Iwan Vosloo via Glass <[hidden email]> wrote:
Hi all,

I am trying to compile C code that calls GemBuilder for C functions.
I take inspiration from
https://downloads.gemtalksystems.com/docs/GemStone64/3.6.x/GS64-GemBuilderforC-3.6.pdf
sections 5.2 and 5.3.

I am doing this on Ubuntu 20.04, using g++ 9.3.0 all of which are
supported according to the above doc.

I also have installed GemStone64Bit3.6.1-x86_64.Linux

I have a simplified test program that just calls a simple function from
libgcits. I can compile and link, but when I run the resultant program
it segfaults when I callthe Gci function. I have to confess that I
haven't touched C in 20 years, so I am probably doing stupid things. (I
had this working with GemStone 3.4.1)

Here is my program (test.c):

#include <stdio.h>
#include <gcits.hf>

int main() {
   const char *unencrypted_password = "abcde";
   char *out_buff;
   char *encrypted_password;
   int encrypted_char;
   unsigned int out_buff_size = 1000;
   out_buff = (char *)malloc(out_buff_size * sizeof(char));
   GciTsEncrypt(unencrypted_password, out_buff, out_buff_size);
   free(out_buff);
   return 0;
}

I build it using this makefile:

COMPILE_FLAGS=-fmessage-length=0 -fcheck-new -O3 -ggdb -m64 -pipe \
               -D_REENTRANT -D_GNU_SOURCE -pthread -fPIC \
               -fno-strict-aliasing -fno-exceptions -x c++

LINK_FLAGS=-m64 -Wl,-Bdynamic,--no-as-needed -lpthread -Wl,--as-needed \
            -lcrypt -ldl -lc -lm -lrt -Wl,-traditional -Wl,-z,lazy

all:
        g++ -I${GEMSTONE}/include ${COMPILE_FLAGS} -c test.c -o test.o
        g++ -L${GEMSTONE}/lib -lgcits-3.6.1-64 ${LINK_FLAGS} test.o -o test


The options above are taken from 5.3 of the doc, except that I link
gcits-3.6.1-64 library directly instead of using the run time loading as
is explained earlier in the doc.

What am I missing here?

Regards
Iwan

--


_______________________________________________
Glass mailing list
[hidden email]
https://lists.gemtalksystems.com/mailman/listinfo/glass

_______________________________________________
Glass mailing list
[hidden email]
https://lists.gemtalksystems.com/mailman/listinfo/glass