0
votes

I have 64 bit installations of db2 express and cygwin. I am trying a very simple test up and running:

gcc ex1.o -o ex1.exe ../../sqllib/lib/db2api.lib

../../sqllib/lib/db2api.lib(DB2APP64.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol __imp_sqlastrt' defined in .idata$5 section in ../../sqllib/lib/db2api.lib(DB2APP64.dll.b) ../../sqllib/lib/db2api.lib(DB2APP64.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol__imp_sqlaaloc' defined in .idata$5 section in ../../sqllib/lib/db2api.lib(DB2APP64.dll.b) ../../sqllib/lib/db2api.lib(DB2APP64.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_sqlasetdata' defined in .idata$5 section in ../../sqllib/lib/db2api.lib(DB2APP64.dll.b) etc..

I tried all -mcmodel options to no avail. Other than that I couldn't find much in the way of solutions to this problem. What do I need to do to get this to link correctly?

(same problem as prior post, but after much searching it seems that others have got something very similar to the above to work, presumably on 32 bit machines)

1
What is wrong with this question? None of the other questions related to this topic that I had read through has solved it. Can anyone shed some light as to why IBM's db2api.lib doesn't link out of the box on a 64 bit system the way it apparently does on 32 bit systems. I fail to follow why this isn't a legitimate question to try to find an answer for. Please comment and I will try to follow whatever advice you give. - user3621949
For example, the only high rated page on this type of error points to a solution that is applicable only if you are writing assembler. That is not the case here. It is simple C program (perhaps I should have mentioned that, but gcc normally implies C if nothing else is said). So what solutions are there to this problem? I could change the compiler or the database, but an informed response would be better before attempting either. - user3621949
What do you know? I solved it. Now if someone says what is wrong with the question, I will update as necessary. I really didn't expect that to work, btw, but then when you run out of options, you try everything. - user3621949
Is building with Cygwin actually even supported by IBM? - Ian Bjorhovde
It works fine with 32 bit db2, which is what I resorted to after my fix above turned out not to be good enough (it got it to link and run without error, but results were later wrong). - user3621949

1 Answers

0
votes

If you are using binutils version 2.24, I suspect the problem to be this: https://sourceware.org/bugzilla/show_bug.cgi?id=16598

Luckily, the Cygwin port of GNU ld is capable of linking directly against DLLs. Specifying the relevant DLL(s) rather than the import library db2api.lib to gcc should work.