1

I'd like to implement some features of libgcrypt in my program, but it is currently running on Windows, OSX, and Linux (Arch/Xubuntu), so I can only really do so if I can build it for all three platforms. On OSX and Linux I had no problem.

I got the sources from the github page for libgcrypt and libgpg-error, and I've successfully built and run the libraries on both Linux and OSX, so I know that my test code is valid (which I am now having trouble with on Windows w/MinGW).

I did the following on Xubuntu (and similar on Arch but using pacman instead of apt-get):

sudo apt-get install mingw32 mingw32-runtime mingw32-binutils

to get the cross compiling tool chain and

git clone https://github.com/Chronic-Dev/libgcrypt.git
git clone https://github.com/Chronic-Dev/libgpg-error.git
cd libgpg-error
autoreconf -vfi
./autogen.sh --build-w32
make
sudo make install
cd ../libgcrypt
autoreconf -vfi
./autogen.sh --build-w32
make
sudo make install

to build, and it successfully builds these files in home/myuser/w32root/:

  • libgcrypt.a
  • libgcrypt.def
  • libgcrypt.dll.a
  • libgcrypt.la
  • libgpg-error.dll.a
  • libgpg-error.la
  • include/

    • gcrypt.h
    • gcrypt-module.h
    • gpg-error.h

I took these files over to windows, and tried compiling the test code (named main.c locally) with

gcc main.c -o main.exe -lgcrypt

but I get undefined reference errors leading me to the conclusion that the library wasn't linked correctly (initially only using libgcrypt.a), so I looked some stuff up, and found that some libraries require a set of files like .a, .def, et al. to work, so I dropped them all in C:\Mingw\lib to see if it made a difference; it didn't. The following was also silent in finding the library file to link, but didn't resolve the undefined references:

gcc main.c -o main.exe -lgcrypt -lgpg-error

So I'm not really sure where to go from here. The readme doesn't get into cross compiling too much, like what files to copy and link once you're on the Windows side. Any pointers (to docs for it I missed maybe?) are appreciated! Thanks a bunch for reading my wall of text.

Dakota West
  • 441
  • 1
  • 4
  • 13
  • What are some of the names for the undefined references? Are there similar names in the librays (grep over `nm libgcrypt.a` looking for the name stripped of prefixes or suffixes). When building for Windows, the external or exported names get decorated differently depending on calling convention and whether its a 32-bit or 64-bit build. You need to have all that stuff lined up for the linker to find things. – Michael Burr Feb 14 '13 at 06:16
  • Ok, How exactly would I do that? I found an answer that suggests the bash command "ldd (libraryname)". Is that what you're talking about? – Dakota West Feb 14 '13 at 14:50
  • I'd try `nm libgcrypt.a | grep gcry_whatever` The command `nm` will dump the symbol names found in an object file or library. – Michael Burr Feb 14 '13 at 15:51

0 Answers0