I've recently started using PDCurses in a C++ game I'm working on. When I compile the program on my own machine (windows) and run the .exe, everything works as it should.

When I take that .exe onto a different computer that doesn't have PDCurses and I try to run it, I get an error about a missing pdcurses.dll file.

After doing a bit of research online, I found out that including the .dll file along with the .exe should make it run but it didn't work for me.

This is how I compiled the program using MinGW:

g++ game.cpp -o game -lpdcurses

So my question is, how do I make this program run on computers that don't have PDCurses setup, and also, is there a way to do this by combining the .exe with whatever additional file(s) the system needs to run the program? I've also read that you can do some sort of static linking but so far I've been unable to find a way to do this.

Thanks in advance for the help.

NOTE: In case it matters, I setup PDCurses following this tutorial: http://comptb.cects.com/1848-adding-pdcurses-to-mingw Not sure if that was the best way to do it but I'm able to compile and run C++ code that uses pdcurses on my computer fine.

Try: g++ game.cpp -o game -Wl,-static -lpdcurses or g++ game.cpp -o game -static-libgcc -Wl,-static -lpdcurses (from http://ubuntuforums.org/showthread.php?t=852552 , your mileage may vary, also this requires a libpdcurses.a file which you may have to create by hand ... by extracting the individual .o files out of a .dll and re-archiving into a .a)

Try: g++ game.cpp -o game -Wl,-static -lpdcurses or g++ game.cpp -o game -static-libgcc -Wl,-static -lpdcurses (from http://ubuntuforums.org/showthread.php?t=852552 , your mileage may vary, also this requires a libpdcurses.a file which you may have to create by hand ... by extracting the individual .o files out of a .dll and re-archiving into a .a)

Hey I tried compiling the program using both of those methods above. When I tried running both of the executables they created, I got the error:

The program can't start because pdcurses.dll is missing from your computer. Try reinstalling the program to fix this problem.

They seemed to run fine if I included the pdcurses.dll file along with the executable though. If this is the case, is there a way I could combing that .dll file with the executable?

... is there a way I could combing that .dll file with the executable?

The sarcastic answer is "yes, make a .zip file that includes the .exe and the .dll file". :)

A different (and somewhat painful) option is to use a Windows package builder (I believe NSIS is free) to package the .dll and the .exe into an installer executable.

A third options is to download the PDCurses source and build the static library yourself:

  • start from the same link where you got the DLL, navigate to pdcurses -> 3.4, and download pdcurs34.zip
  • run './configure' (possibly with command-line flags to make sure it builds the static library libpdcurses.a) and then 'make'
  • then use one of the command-lines above to link the static library into your .exe (you may also need a -L/path/to/dir/containing/lib flag so the compiler can find the static library you just built).

The sarcastic answer is "yes, make a .zip file that includes the .exe and the .dll file". :)

A different (and somewhat painful) option is to use a Windows package builder (I believe NSIS is free) to package the .dll and the .exe into an installer executable.

A third options is to download the PDCurses source and build the static library yourself:

  • start from the same link where you got the DLL, navigate to pdcurses -> 3.4, and download pdcurs34.zip
  • run './configure' (possibly with command-line flags to make sure it builds the static library libpdcurses.a) and then 'make'
  • then use one of the command-lines above to link the static library into your .exe (you may also need a -L/path/to/dir/containing/lib flag so the compiler can find the static library you just built).

I'm not too familiar with using the command line yet so I was wondering if you could be a bit more specific in your description.

1. When you say to use command-line flags to make sure it builds the static library libpdcurses.a, what are these flags that you're referring to?

2. Also you said to use one of the command-lines above to link the static library. Does it matter which one I use?

Thanks for your help thus far.

Edited 5 Years Ago by massivedynamic: n/a

Hi massivedynamic,

Don't worry about being new to the command-line, we were all there at some point, and the best way to become more comfortable is to keep at it.

>> use command-line flags to make sure it builds the static library libpdcurses.a
I was referring to potential optional command-line flags to ./configure, I'm looking in more detail now. Trying just the default './configure' (with no flags, should work for most cases) ... looks like I don't have sys/ipc.h header installed, so I'd have to update my cygwin installation to proceed.

In any case, after poking through a good portion of the 'configure' script, I don't see any obvious indication that there's an option to build static versions of the library, so forget that.

I'm hoping somebody with more recent memory of how to force static linking will hop on this thread!

This article has been dead for over six months. Start a new discussion instead.