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).
Related
I'm having a complete program, but now, I want it to be able to be updated. So I would like to change the "code" in the executable by the new code without having to recompile it.
Is it possible? If yes, how can I do, I coding in C++ in Qt Creator.
Thanks for any advise/clue
C++ can't do this. With QT, you could have a javascript implementation of the code you want changed and update that.
I did exactly what Jon told me : simply replace the old exe by the new one
While you can't technically do this in C++ without recompiling, if you don't want to rewrite in another programming language, you could write a small helper program that (while the original program is not running) recompiles the first program.
If you really wanted to do this (it's not hard at all) I'd look into GNU g++.
If you're using Windows, you'll probably want MinGW (which I believe comes with g++ installed). Both are free/open source and fall under the GNU GPL (something you need to look at if you are planning on selling your program. However, you're free to give it away)
Basically you could run your program, call another program before closing, and have that program act as a script to call g++ to re-compile your code. I've done this before, but for faster debugging rather than actually releasing a program that works that way.
Not sure this answers your needs, but did you look into the ClickOnce platform? Although the code still gets recompiled on your server the client executable gets updated via ClickOnce.
This is basically a duplicate of:
Netbeans or Eclipse for C++?
But, that question as 3+ years old, and a lot has changed since then.
I have a large code base with a custom (but Makefile based) build system. The areas I am specifically wondering about include:
Syntax highlighting
Code navigation.
Code hints.
"ReSharper style" code helpers.
Documentation integration.
Debugger UI and features.
Has anyone had the chance to evaluate both Netbeans and Eclipse?
EDIT: As a followup question, are any of the Netbeans users here concerned with its future given Oracle's recent bad history with "open" efforts? (Open Solaris, MySQL, Open Office)
Thank you
I cannot comment on eclipse, but on netbeans 7 I will say things that are very important for me and that work fine so far:
code completion, go to declarations
pkg-config automatic include management for parsing
stuff that sometimes works and sometimes don't
find usages, sometimes it might fail to find usages in other open projects
debugger sometimes gets confused with unittest-cpp macros and it will not go on the appropiate line
stuff that are not yet working and i care deeply:
C++0x syntax highlighting (auto, lambdas, enum class, variadic templates, none of them are recognized by the built-in parser)
stuff that is not quite working but i could not care less:
git integration. I enjoy using git from command-line so this is a non-issue
in all, the IDE is very usable. I hope to have a chance to try out latest cdt on Indigo Eclipse, but so far i haven't that much of a real reason to investigate
I cannot comment on Netbeans, but I can offer you information on Eclipse. I work with C++ on UNIX systems, and I have started to use Eclipse when exploring large code bases that I know little about. I don't use it to build, but it would be easy to integrate our build system with it as one only needs commands.
Eclipse has most of what you are looking for: (I'm speaking of Eclipse/CDT)
Not only can you completely customize your syntax highlighting, you can also have it format the code with templates. My company has a code standard for spacing, tabs and formatting of functions and conditional code, and with little effort I was able to modify an existing template to meet our code standards.
The navigation is not bad, if you highlight and hover over a variable, it shows you the definition in a small pop-up bubble. If you do the same for a type, it will you show you where the type is defined. For functions, it will show the first few lines of the implementation of the function, with an option to expand it and see the whole function. I find all of these nice for code discovery and navigation. You can also highlight a variable, and use a right-click menu option to jump to its declaration.
I suppose by code hints you are referring to something like intellisense? This is the main reason why I use Eclipse when looking over a large code base. Just hit the '.' or '->' and a second later you get your options.
The debugger UI is quite capable. You can launch gdb within the tool and it allows you to graphically move through your code just as you would in a tool like ddd or Visual C++. It offers standard features like viewing registers, memory, watching variables, etc.
That being said, I have found some weaknesses. The first is that it doesn't really strongly support revision control systems outside of CVS and SVN very easily (integrated into the GUI). I found a plug-in for the system we use at my company, but it spews XML and Unicode garbage. It was easier to just use the revision control on the command line. I suspect this is the plug-in's issue and not Eclipse. I wish there were better tool integration though.
The second complaint is that for each project I have to manually setup the include directories and library paths. Perhaps with an environment variable this could be circumvented? Or I may just do not know how to set things up correctly. Then again if it is not obvious to a developer how to do this, I consider that a weakness of the tool.
All in all I like working with Eclipse. It is not my main editing environment, but I appreciate it for working on large code bases.
I'm a huge fan of Netbeans. I am in a similar situation to yours, but creating the project was very easy. Just point Netbeans at where the code is checked out and it figures out most things for itself. I rarely have to do any configuration. One thing to note though, if your tree is very large, it can take some time to fully index - and while it does, memory and cpu will be hosed on the box.
The integration with cvs is awesome, and the Hudson integration is very cool for CB. I've not used Git myself, though I should imagine it's a no-brainer.
One thing that does irritate me no end is that it does not behave very well with code relying heavily on templates. i.e. shows lots of warnings and errors about types not being found etc.
I have not used the latest version of Eclipse, I tried the major release before the current one and gave up because it did not have the same smooth project integration with the makefiles etc. I find it's not as nice if you don't want to use it's make system - though I could be wrong.
I don't use any of the code formatting provided, I instead prefer something like AStyle instead. I know that NetBeans does a good job with Java - but have not used it for C++. CDT I seem to remember doing some odd stuff with indentation when formatting C++ code - esp. if templates are involved - but that was atleast two years ago.
Hope some of it helps - the best way to do this is to download and try for yourself and see what works for you. Anything we tell you is purely subjective.
I used to work with Netbeans with MinGW, I Just tried 7.0.1.
I currently use Eclipse Indigo with CDT and MinGW - It's better performance wise (less CPU & Memory).
Netbeans creates a makefile to compile all the time,
In Eclipse you can build directly with the CDT-Toolchain or use Makefile - Eclipse is more flexible.
Debugging: Netbeans might be better in Solaris/Linux.
I Personally rather eclipse over Netbeans, I think eclipse is more professional.
One particular issue that causes me quite a lot of grief with Netbeans 7.0 is that it tends to want to work with utf8 files, and not all of out c++ projects are utf8. It will issue a warning about opening such a file, and if you do open it, will corrupt said file, which is a pain.
I've not found out how to properly make netbeans handle this. Apparently the encoding can be changed, but for the entire project. So presumably changing it to us-acii would stop this problem, although non ascii characters wouldn't display properly.
I have the source code to a relatively complex C++ application that involves lots of libraries, dependencies, etc. I am trying to take it and add a Cocoa GUI to it. I have failed so far at the following :
Create a new Cocoa xcodeproj and try to move all the libraries, etc. into the Cocoa app. I just can't get it to build. Thousands of errors no matter what I do. My skill here is just not good enough to figure out what's going on.
So, I am thinking that an easier method must be to make the appropriate changes to the C++ xcodeproj in order to make the main() function launch an NSApplication instead of whatever it is doing right now.
Does anyone know what I would have to do, precisely, to make this happen? I am new to Cocoa so I am unsure of what I would have to add. For reference, the main.cpp of the C++ app is actually really simple:
int main() {
ofSetupOpenGL(320,300, OF_WINDOW);
ofRunApp(new testApp());
}
What I'd like to do is make all the right changes so this can be:
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[]) {
return NSApplicationMain(argc, (const char **) argv);
}
And have the old xcodeproj compile with all the "stuff" still in it, and then when it is run, open up the Cocoa window.
It should be noted that the C++ xcodeproj appears to have absolutely nothing Cocoa-related, or even Objective-C related in it, so we'll have to add everything that is relevant and make all relevant changes.
Any ideas?
(Or, alternatively, if you know how I might easily get all the stuff from the C++ xcodeproj to build in a squeaky clean Cocoa xcodeproj, let me know, but this seems more complex to me at the moment.)
Thanks!
Well, I have two ideas...
Do You really need Cocoa? Mac support could be added with QT, wxWidgets and others.
You don't have to transfer every C++ line to Objective-C++. Objective-C++ can easily handle C++ code, You just have to change .cpp -> .mm and, of course, re-write some code relative to the UI. I think, the best way here is to create a blank Cocoa app from XCode and fill it with the old code step-by-step. First get You OpenGL stuff working with Cocoa app, than transfer C++ code renaming the files.
Hint:
You can cover some part of Your code with "blank declarations", i.e. define an empty macross instead of real function, put some blank classes with an empty methods if they are really necessary. Getting all the stuff compiling is the first and big step here. When everything compiles - put another part of the real code into the project and fix it to compile.
Unfortunately, I don't know better solution. I have re-factored huge projects few times and every time, on every platform and programming language(s) the recipe was the same. Good luck!
chances are, this will not go smoothly if you don't know c++ or similarly, cocoa.
otherwise, most of the transition will be monotonous, if you do know what you're doing. otherwise, prepare to learn a few things about objc.
first: don't bother converting a functioning c++ program's implementation to objc. it's a huge waste of time. you just wrap, bind, and alter the program to operate in that context. you don't have to write everything in objc.
second: you'll have to write some objc bindings/wrappers to use the c++ program. you'll have some wrapping to do, particularly for the ui elements and user events.
third: sources should compile as-is. you just add them to your new cocoa template project and gcc will compile it as a cpp file by default if it has the a recognized c++ extension. to use c++ and objc, use objc++ FILENAME.mm (you could also use .M, but that is not supported as well). even better, put the original cpp sources in a separate library, which the app links to.
fourth: now that you have a cocoa project template and compiling cpp sources, add the wrappers/bindings so the cocoa events/drawing performs in that context. based on your example code, your starting point uses Open GL so you'll have to use something like an NSOpenGLView if you want a Cocoa app. what exactly you'll need to implement depends on the project.
your main function should call NSApplicationMain, then your initial entries for writing the bindings to the c++ code will likely be event handling, NSWindow, NSView, and maybe NSApplication.
if you're new to objc, you'll probably have a bit of ramp-up.
I am writing a similar application but as I intend for it to be cross platform (Mac primarily and then Windows) I am keeping the backend deliberately as a C++ library. I will then provide whatever frontend GUI is appropriate (Cocoa on Mac and MFC on Windows). There is no conversion to do - you simply need to integrate what you already have.
Even though it's an old post, I didn't see this answer yet.
Your code
int main() {
ofSetupOpenGL(320,300, OF_WINDOW);
ofRunApp(new testApp());
}
Looks like Open Frameworks code. Why don't you download the Open Frameworks Mac XCode edition here, and try to put your sources in one of their example projects. For example the OpenGL flockingExample?
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.
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.