Encrypting and compressing using p7zip - c++

I am trying to replace the usage of 7zip in my QT Xcode project. Currently the files are archived using a password and my project on Windows uses 7z when accessing automatically opens the file.
I have found p7zip to be the port of 7zip for linux/mac
The objectives are:
Open existing 7zip archived files with password
Save stream with password as a single file.
I built with the following commands
$cd path/to/p7zip
$cp makefile.macosx_64bits makefile.machine
$make 7z
It built without any errors but I am not able to find *.a or *.dylib files. Instead I find the following in the bin folder
7z
7z.so
Codecs
Codecs has Rar.so
That is a linux lib file isn't it?
I am very new to the Mac dev, so any help or suggestion would be helpful. I am not able to find an example program too.

Related

Cannot load any image with CImg

Any time I try to load an image I get an error saying CImg<unsigned char>::load(): Failed to recognize format of file. This happens for both jpg and png files.
I have found other posts about this saying to define cimg_use_png and cimg_use_jpeg, but then I get compilation errorstelling me I need png.n and jpeglib.h. Not sure where I'm supposed to get these from.
I'm not sure where I've gone wrong, so I don't know what to ask specifically. What's gone wrong?
If you want to open JPEG images, you need to install libjpeg and compile and link against it.
If you want to open PNG images, you need to install libpng and libz (for the compression) and compile and link against them.
At the moment, you should be able to use NetPBM format images - i.e. PBM, PGM and PPM.
Well, after two painful days of trying to work out how on Earth Visual Studio 2017 works, and how to install and integrate libjpeg with it, I can now explain how to install CImg and libjpeg on Windows.
Step 1
You need to have Visual Studio 2017 installed, which means you need Windows 7 with SP1 or better. When installing it, be sure to include "Windows 8.1 SDK"
Step 2
Download libjpeg from the IJG website. I took jpegsr9b.zip as it is the latest.
Step 3
Unzip the file and store it in a directory called libjpeg in your HOME directory.
Step 4
Go to Start>All Programs>Microsoft Visual Studio 2017>Visual Studio Tools > Developer Command Prompt for VS2017
Navigate to the directory you just unzipped. That will be something like this:
cd libjpeg
cd jpeg-9b
Step 5
Now you are going to need to find a file called win32.mak. I found mine in C:\Program Files\Microsoft SDKs\Windows\v7.0\Include. Yours may be somewhere else if you have Windows 8.1 SDK. Anyway, wherever it is, you need to add its containing directory to your includes. So I did:
set INCLUDE=%INCLUDE%;C:\Program Files\Microsoft SDKs\Windows\v7.0\Include
Step 6
Now run nmake to get your SLN - some weird Microsoft "solution" file. The command is:
nmake -f makefile.vc setup-v10
And you should get a file called jpeg.sln - hurray!
Step 7
Now start Visual Studio 2017, and open the jpeg.sln file you just created and build the project. It will create a Release directory in your libjpeg directory and inside the Release directory you will find jpeg.lib. You have now installed libjpeg.
Step 8
Close that project, and start a new C++ command-line project and write your CImg-based program. I wrote the simplest ever:
#define cimg_use_jpeg
#include "CImg.h"
using namespace cimg_library;
int main() {
CImg<unsigned char> img("C:\\Users\\Mark\\test.jpg");
img.display("Image");
return 0;
}
Step 9
Download CImg.h from Github, and save it in a directory called CImg in your HOME directory.
Step 10
Now tell Visual Studio where the include files (for CImg and libjpeg) are and where the library files (for libjpeg) are:
Step 11
Now tell Visual Studio 2017 that you want to link with libjpeg:
Step 12
Now you can compile, link and run your CImg program and load JPEG files and display them on the screen!
If you are using cmake on Linux/macOS, this answer shows you the way.
If you are compiling on macOS from the command line, you'll need to have XQuartz installed if you are display images on the screen, and you'll want something like this:
g++ -std=c++11 sample.cpp -o sample -I /opt/X11/include -L /opt/X11/lib -lX11 -ljpeg -lpng -lz
If you want CImg to work with jpeg or png images, you need to supply appropriate library.
Here's a tutorial how to install libjpeg to Visual Studio project. It's basically a 2019 update to Mark Setchell's answer.
How to install libjpeg to your project
Download jpegsr9c.zip (or newer) zip with source code
Extract the archive to a folder.
Copy the address of the folder extracted from archive
Search for Developer Command Prompt in Start menu
Navigate to extracted folder in Developer Command Prompt:
cd "C:\Users\HP\Downloads\temp\jpeg-9c"
Use right click to paste.
Run this command:
NMAKE /f makefile.vs setup-v15
Open jpeg.sln (which was now created).
In Solution Explorer, right click on the project. Select Retarget projects. Confirm prompt.
If you want to build your project for 64-bit platform: Right click on solution, select Configuration Manager and add new platform x64
Build solution
Now let's move to your project with CImg. Create a folder jpeglib in your project (it's IncludedLibraries\jpeglib for me). And add it to Project Properties -> C/C++ -> Additional Include Directories and to Project Properties -> Linker -> Additional Library Directories
Add jpeg.lib to Project Properties -> Linker -> Input -> Additional Dependencies
Copy x64/Release/jpeg.lib to this folder.
Search for all header files (`.h) in jpeg project and copy them to this folder.
Add #define cimg_use_jpeg before #include "CImg.h" in your project
All done! CImg is now able to read and save jpeg files.

Build all dependencies to one file

I'm working on a small installer program (silent install of setup, unzipping, ...).
I wondered how to build everything into one .exe file.
I don't even know HOW to search for that correctly.
Could you tell me some keyword to search for?
E.g.:
I have Setup.exe and Configs.zip for my installer to use.
After compiling I just wanna have 1 file (Install.exe) which has Setup.exe and Configs.zip included and can use them.
You could use resources that is a normal way to store such files. You can extract that files and execute that than from the temp directory.

Creation of libBox2D.a when Box2D is compiled?

I am trying to get the most recent version of the libBox2D.a file for updating an old project that uses Box2D. I am using Code::Blocks and Windows 7 64-bit.
I have added the Box2D folder into a Code::Blocks project, and got the HelloWorld.cbp applet to build and run. I expected a lib folder to be created and the .a file to be there, but it's not. The question is, How does libBox2D.a get generated, and where does it go?
Assuming your codeblocks project is setup correctly, the libBox2D.a library gets produced as the end result of building the corresponding project file. What you have to figure out is whether the project is setup to build Box2D as a shared dll or as a static library.
You can find the destination of the build output under project options->Build targets->Output filename. That field should tell you where to find the output. If that doesn't help, you can open a cmd.exe shell and go into Box2D's working directory and do a manual search. For example:
cd YOUR_Box2D_DIRECTORY_GOES_HERE
dir/s/a/w lib*.a

Output after building chromium source code on ubuntu linux

I followed these steps to build chromium source code on linux.
I build only chrome. Finally i have finished it successfully.
For output i opened out/Debug directory, i found some files but, i don't know which file is executable or anything extra i have to do to create executable. I didn't get any information from above link also after building source code.
Please help me regarding this. Thanks.
Just Run the shell script file chrome-wrapper in out/Debug directory, it launches Chrome Browser automatically.
After building chrome (via make chrome, or the like), you'll have an executable binary at out/Debug/chrome. Other packages (notably the unittests) generate similar binaries: out/Debug/unit_tests or out/Debug/browser_tests for example.

Build libiconv library

I want to convert S-JIS string to EUC string. I searched on the internet and find out libiconv library which can do that. I downloaded version 1.9 for windows and did converting.
However, there are some characters which this library can not convert. I also found new version of libiconv 1.13 but there is no library for windows to download, just have source to build.
I tried to build in cygwin and get some files as the below.
libiconv.dll.a
libiconv.la
...
Could you please to guide me to build library.
Thanks,
Ankata
I do not have experience about using libiconv under windows. But it seems that your problem is mainly a compiling problem.
libiconv.dll: the file where libiconv function entrys is stored
libiconv.la : in my opinion, should be a lib file used to link the entry address information to your programm
Besides, these file, you also need the "header" files that libiconv should provide.
You include the header file when you edit your code using libicon, and add the libiconv.la file to your link file list when you compile your code.
If you want run your program, you should put the libiconv.dll under the exe file folder.
As well, if you want to run your program out of cygwin environment, you may also need to copy cygwin1.dll under your exe folder.
Just some suggestion, wish it could help you.