Compile/use unrar C++ source for iphone app? - c++

Writing an app that will include the ability to decompress zip and rar files. I think I'm OK on how to handle the .zips but .rars seem a little more trouble. I noticed that rarlabs has source available but it's C++. Is there a way to compile, wrap or otherwise use this code within an iPhone app?
Reference: http://www.rarlab.com/rar_add.htm
Open to alternate suggestions on how to handle .rar files as well.
I'm still pretty much a newbie so please explain in small words :)

If all you need is to decompress RAR files, this library may be much easier for you to compile since it's a single C source file:
http://www.unrarlib.org/features.html
I had looked at compiling the library you mentioned, but there were a lot of errors and it was not initially apparent just how to resolve some of them (file type was not the issue).

Objective-C++ allows you to drop C++ code unaltered into an Obj-C source file (and give it a .mm extension). It really is that simple - I didn't believe my eyes the first time I did that, but it was super easy.
You can even mix C++/Obj-C types. See this project for a good example (it's a pretty small library, so it's pretty easy to navigate and see how they structured it): simple-iphone-image-processing. See the Image class in particular.

Related

Access violation in module ilink32.dll

I have a gigantic C++ Builder 6 solution, when I try to compile it I get the following error when the linker starts its work:
It translates to:
---------------------------
Fehler
---------------------------
Access violation at address 0660EE22 in module 'ilink32.dll'. Reading from address 00000000.
---------------------------
OK
---------------------------
Does anyone have an idea how this comes and how I can fix it?
EDIT 1
Important note, the code sometimes compiles, mostly then, when I reset the working copy and then just modify the stuff in sublime text and use C++ Builder only for compiling. Including, I don't open a single file.
EDIT 2
Some more details, the project has about 80.000.000 lines of code (according to C++ Builder). The largest file is about 70.000 lines, but you cannot say clearly, because there are a lot of
#ifdef XY
#endif
Things.
The code itself is copy-paste from an existing part and got reviewed by some coworkers. So I think it is a bug in C++ Builder, because it actually works if I just use Sublime Text or Notepad++ to edit the stuff and then use C++ Builder to build it, it works (at least sometimes).
To be honest, I myself don't think there is a real solution. But I hope someone knows this bug. According to Google, the ilink32.dll is a C++ Builder library that is linked automatically.
Maybe someone has a solution.
The ilink32 has always had a lot of bugs. There's no chance of getting anything fixed in non-current versions , so your options are:
Look for workarounds on QC
Find your own workaround
Here are some QC searches that may or may not be useful to you.
AFAIK it is not possible to use a different linker. However you can turn on (or turn off) Incremental Linking via the project options and see if that makes a difference. Incremental linking is a speed optimization, it makes no difference to the semantics of linking.
the project has about 80.000.000 lines of code (according to C++ Builder).
Well, that number counts all lines in precompiled headers for each source file so maybe it doesn't mean much.
70K LOC is large for one source file; perhaps you could try refactoring code to have smaller object files, especially if it does seem that adding to a big file does trigger the problem.
It might be possible to identify which change you are making that is triggering the bug. For example it might be increasing a particular thing past some limit (e.g. size of one object file , number of object files, size of static data, etc.)
You could delete the precompiled header files (that is vclNN.csm, vclNN.#00, vclNN.#01, etc.) that are built and saved by default in the BCB6 lib directory. Perhaps they got corrupted or could be rebuilt better. PCH management is difficult in BCB6 anyway. (I ended up defining my own "all.h" and having every source file do #include "all.h" #pragma hdrstop). Later versions of CBB XE allow PCH injection making this process a lot tidier.
Have a look at the actual link command being passed to ilink32 and see if there are any unnecessary object files or libraries in it. You could delete and re-create the project files as they can build up crud over time as a project is developed. Actually that is probably a good idea anyway.
Another possibility might be to group some of the code into static libraries .
In all cases make sure you are using good source control so you can reverse out any failed options that might make things worse

writing out binary files using xcode

I'm using xcode 6 to code up a C++ file-based array list (vector) for my Data abstractions course. This, of course, requires writing out binary files. I'm using the C-library functions (fopen, fclose,fread,fwrite,fseek, etc.) since I like those more than the C++ functions. I'm having no issues with my code per se. Everything's working fine, but the issue comes when I execute.
Xcode will "run" everything, but it won't give me out a binary file. I think this has something to do with xcode itself not writing out these files since, all in all, it's a pretty costly thing to do. I can do it through the terminal using g++ but it would be a lot easier if I could do it through the xcode compiler so I'm not having to switch to a terminal window every time to test my code. Let me know if you need any clarification and thanks so much in advance.
The issue might be your working directory not being set correctly inside Xcode.
The file is probably getting written, just not to the right place (or the place you expect it).

Decoupled version of hash_map/unordered_map

I'm writing an embedded application, and the environment I use does not, unfortunately, have C++11 support at present.
I need to implement a hash/unordered map (a regular std::map won't do for performance reasons), but can't seem to find a way to do it cleanly.
Boost doesn't want to work without bringing in practically the whole library. Even the original STL hash_map from SGI wants several headers, and duplicates standard library functionality, causing ambiguous function calls. It's a real mess.
For ease of implementation, versioning, quality control, V&V, etc. I really need something that leverages the existing standard library and exists in only a few header files that I can put right in the same folder as all the other source/header files. Does such a thing exist, or am I without hope? I've searched for a long while, but have come up empty-handed.
Thanks very much for any help. I can certainly clarify further if necessary.
Did you look at the GNU implementation? On my Ubuntu Machine, unordered_map.h does not include anything. This file is located at
/usr/include/c++/4.6/bits/unordered_map.h
which is about 400 lines although the file "unordered_map" in /usr/include/c++/4.6/ has more headers but you can tweak those I guess.
I think you can find the source code for implementation from GNU.org (?) and compile it yourself?

Is there a decompiler that will work on Visual Studio 6 C++

I have a project that I am trying to fix from a guy that left (let go) from my company. He has violated every fundamental principle of software engineering, not using source control, not backing up the source before you make more changes, etc. etc.
I need to make changes to an application that is in the field and I don't have the original source code, but I have an executable. What I need is a decompiler that will decompile a Visual Studio 6 C++ application and provide me with some type of source code. Anyone got any ideas.....
Well there's the Decompiler from Hex-Rays: https://www.hex-rays.com/products/decompiler/
It is pretty good for the fact that it is creating C code from Assembler but it works pretty good. It's also pretty expensive
Edit: Additional note it is combined with IDA Pro the pretty well-known disassembler from them. That already can show you a lot of information in the combination with the decompiler it is even easier to reverse code.
I've used RecStudio (rec22) and IDAPro to try and decompile a C++ project, together they probably wouldn't have been enough to do the job I had except that I worked out the demo project the program was based on so they gave just enough info that I could make something like the same project again.
In the end one other thing I was doing was compiling code that I thought matched and checking that I got the same result in the decompiler.
Good Luck.
Decompile to what - assembler?
There isn't anything that is going to give you meaningfull C from an exe.

Overview look of header inclusions

When a project grows it becomes hard to get an overview of header inclusion. I've noticed our object files have grown rather large and so I'm thinking there's a lot to be won by rearranging dependencies. This is where the problem begin, I know of no convenient way to actually get an overview on what headers actually get included for a specific source file. There's the possibility of outputting the pre-processed source files, that however creates huge files with loads of irrelevant information. I'm thinking there must be a tool for this, but I can't seem to find any. I'm on windows, so in case anyone know of a good tool / way to actually do this for windows I'd be eternally grateful.
Visual C++ has the /showIncludes switch, which causes the compiler to output a message when an include is encountered.
This isn't a tool, but lays out some basic principles for good design of header file #includes:
http://www.eventhelix.com/realtimemantra/headerfileincludepatterns.htm
doxygen makes nice #include file dependency graphs too, if you want to see how all your headers fit together.