[Glass] GemBuilder for C compilation on 3.6.1

Norm Green norm.green at gemtalksystems.com
Mon Jun 21 09:22:18 PDT 2021


So you were trying to statically link you application with 
libgcits-3.6.1-64.so ? Statically linking a gem executable is not 
supported. We would need to provide you libgcits-3.6.1-64.a. Can you 
please explain why you need to do this?

If you were trying to dynamically link then the solution I presented 
should suffice.

Norm




On 6/20/2021 11:52 PM, Iwan Vosloo via Glass wrote:
> Thank you Norm,
>
> Yes, that works, and I saw that is what's recommended in the manual. 
> The problem is this is a simplified example of a larger project where 
> I have other constraints. One of these in the past was that we had to 
> link libgcits explicitly and could not make use of GciTsLoad.
>
> Either way - I can use this to try and see if I can get GciTsLoad to 
> work in our environment. I can't remember why we had that constraint 
> before.
>
> However, surely linking libgcits directly should also be possible?
>
> The only thing I see changed in the header files is that these 
> functions have GCI_WEAK appended now, which was not there before. It 
> is defined on Linux as __attribute__((weak))
>
> Thanks
> Iwan
>
>
> On 2021/06/21 01:06, Norm Green via Glass wrote:
>>   Iwan,
>>
>> I was able to get it work with the following changes based on your code:
>>
>>
>>
>> // test.c
>>
>> #include <stdio.h>
>> #include <gcits.hf>
>>
>> int main() {
>> // load the GciTS library first
>>    char msg[256];
>>    const char* path = NULL;
>>    if (! GciTsLoad(path, msg, sizeof(msg))) {
>>      printf("ERROR: GciTsLoad failed %s\n", msg);
>>      exit(1);
>>    }
>>
>> 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;
>> }
>>
>> -------------------------------------------
>> # test.mak - link with gcirtlobj.o instead of libgcits. GciTsLoad() 
>> will load the shared lib.
>>
>>
>> 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++ ${GEMSTONE}/lib/gcirtlobj.o ${LINK_FLAGS} test.o -o test
>>
>>
>>
>>
>>
>>
>> On 6/20/2021 1:39 AM, Iwan Vosloo via Glass 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
>> Glass at lists.gemtalksystems.com
>> https://lists.gemtalksystems.com/mailman/listinfo/glass
>
>



More information about the Glass mailing list