2

I created a program and I want to run it on another PC. My program uses libzip.dll. therefore i have to keep this dll file with my exe file everywhere. How can I make the dll independent so I ship only exe file to other computers and it shouldn't give error of missing libzip.dll file.

Currently I am compiling like this

g++ -I C:\MyProject\libzip myprogram.cpp -L. -lzip -static-libgcc -static-libstdc++

as -lzip seems to be dynamic library I think that's why I must keep it with exe. I tried to add like -static-lzip but it doesn't work.

fecub
  • 945
  • 10
  • 27
Saim
  • 39
  • 4
  • You probably have to compile libzip yourself with the compiler you are using. Edit: if you are using msys2 for your mingw it appears that they have a package containing static libraries since 2018: [https://github.com/msys2/MINGW-packages/pull/3572](https://github.com/msys2/MINGW-packages/pull/3572) – drescherjm Aug 28 '21 at 16:42
  • See here on how to install msys2: [https://www.msys2.org/](https://www.msys2.org/) and here is the package you need to install if you are using 64 bit code: [https://packages.msys2.org/package/mingw-w64-x86_64-libzip?repo=mingw64](https://packages.msys2.org/package/mingw-w64-x86_64-libzip?repo=mingw64) – drescherjm Aug 28 '21 at 17:11
  • i have MSYS2 in my computer, its a command line. but what to write there? i am sorry i am totally noob in this. can you guide me in steps, what to write in msys console ? – Saim Aug 28 '21 at 17:13
  • The instruction is in the listing for the package: `pacman -S mingw-w64-x86_64-libzip` will install the 64 bit libzip package which includes the static library `/mingw64/lib/libzip.a` you can see that in the file listing for the package. – drescherjm Aug 28 '21 at 17:14
  • Thanks for assistance, btw i am using mingw-w64 i686-8.1.0-posix-dwarf-rt_v6-rev0 .. i want to run my app on both 32 and 64bit. – Saim Aug 28 '21 at 17:19
  • Then you probably want this package: [https://packages.msys2.org/package/mingw-w64-i686-libzip?repo=mingw32](https://packages.msys2.org/package/mingw-w64-i686-libzip?repo=mingw32) – drescherjm Aug 28 '21 at 17:21
  • I am using g++ compiler from mingw-w64, i am not using msys but its installed and i also downloaded the package, but still i am getting same error on my compiler g++ .. any idea please. – Saim Aug 28 '21 at 17:34
  • Be sure you have `libzip.a` in your package. Then use `g++ -static myprogram.cpp -lzip` . Notice "-static" will use only static libs (.a), and link all libs to the executable. – Ripi2 Aug 28 '21 at 18:35
  • no i dont have libzip.a file in my libzip folder. – Saim Aug 28 '21 at 18:46
  • 2
    Step 1: Stop using the version of MinGW you're using right now. Might be a good idea to uninstall it, to make sure it doesn't get in the way. Step 2: Follow [this guide](https://stackoverflow.com/questions/30069830/how-to-install-mingw-w64-and-msys2) to properly set up MSYS2. Step 3: Use the command Ripi2 told you. It should work then. – HolyBlackCat Aug 28 '21 at 20:21

0 Answers0