Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
So about 2 weeks ago, I started learning C++ and Lua, and I would like to be able to:
compile C++ code (it would be a nice bonus if i could have a C compiler as well, as that's next on my list of languages to learn)
interpret (is that correct terminology?) Lua, and
do all of this from my usb drive WITHOUT downloading anything from the internet or changing the path variable. (I will mostly be working on school computers.)
As a side note, I have fallen in love with Sublime Text 2 (the portable version of which is already on my usb drive). If it's ABSOLUTELY necessary, I'll make do without it, but I would prefer being able to use it wherever I go.
Please be patient with me, as i have mentioned before, I just started learning how to program, and I have little to no knowledge on how things work. I have seen similar questions, but they never seem to help me much due to my limited knowledge, so PLEASE don't mercilessly close my question like others I have seen on this site.
Thank you in advance!
I recently added a page on Lua WIKI (great source of info) that may help you. It is a tutorial for complete newbies on how to build Lua from the sources using only free and "portable" (in the sense of "can be put on usb drives") tools. It is meant for Windows OS users. Do not forget to check the official getting started page and the main Lua site as well!
The fact that you cannot download anything is quite restrictive (how could you get a free compiler then?). Anyway as greatwolf mentioned TDM-GCC is a great C/C++ compiler for 32 bit x86 PCs. It is also patched to be perfectly "portable": I usually use it from a portable USB HD. The tutorial I mentioned shows you how to download it and "install it".
Note that although your sysadmin at school may have blocked your ability to change the path variable globally, you can set it for individual processes ("launched programs") using simple batch files (aka Windows command shell scripts).
Create a file named "myshell.cmd" with this content:
#set path=%path%;c:\the\path\to\my\app&cmd /K
the part c:\the\path\to\my\app must be the actual path of the directory (folder) where the application executable is placed. When you double-click on myshell.cmd a black box will open (assuming your sysadmin hasn't blocked this feature) where you can invoke the app executables.
For example, if you "installed" the TDM_GCC compiler in c:\myprogs\GCC inside that dir you will find a subdir named bin. That subdir must be put in the path, so your myshell.cmd file will be like this:
#set path=%path%;c:\myprogs\GCC\bin&cmd /K
Then in the "black box" I mentioned you can invoke the compiler typing:
gcc --help
As for your learning path, if you intend to learn both Lua and C or C++, I will advice you to try C instead of C++. C++ has more "high-level" features, but it is huge and although Lua can be used embedded in C++ code (of course this is an advanced topic anyway), it is designed to be directly embedded in a C application (it has an API which conforms to C conventions), so for a beginner probably the path Lua --> C --> C+Lua would be a bit easier. C in itself, although difficult to master, is a rather minimalistic language, so the information to digest about it is not that big.
Not to discourage you, but IMO both C and C++ are not the most suitable languages for absolute beginners (they are plenty of pitfalls and have almost no "safety nets" for beginners). But that's up to you, it heavily depends on your skills, dedication and motivation ;-)
Hope all this helps.
For windows,
Take a look at
http://nuwen.net/mingw.html
You should be able to extract the download to a usb directory. Then you can click on the .bat file open a command prompt with the correct path settings.
As a bonus, it already includes prebuilt boost, which will make your c++ use easier.
For the C/C++ piece would also recommend you start with C. Not for ideological reasons, just that it's a lot simpler if you're trying to work out the basics of compiling/linking etc.
As a first C compiler I would recommend the tiny C compiler
Tiny C Compiler
It's one of the simplest to get your head around that I've seen and you can still build lua libraries etc.
Once you're comfortable with that then progressing to one of the more powerful environments such as gcc under MingW or Visual C++ should be a bit less daunting.
Lua is trivial. Download the binaries, put them on your drive, and configure Sublime Text to invoke them on Lua files.
C/C++ is more complicated only because of the range of options is so vast. I use a 2003 version of Microsoft Visual C++, which covers my needs. I find a copy here.
Keep in mind that C++ is a vastly more complicated superset (non-strict) of C, so you're going to learn most of C in the process of learning C++. IMO, learning C first is better for a whole host of reasons. You'll hear some people argue the opposite, but in this case there's a clincher: Lua is written in C and its API is designed for C. Exposing idiomatic C++ (i.e. objects) to Lua is a big ball of complexity that you just don't need right now, while learning two languages.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
In my school, they only teach on Tubro C++. I can program well in the DosBox but I want to develop my own applications, algorithms, etc. The problem is that I don't know where to start. The spectrum is so broad, I don't know what gcc or g++ are other than the fact that they are compilers.
I don't know how to use VS Code (mac) to compile & run. I don't know anything about the modern C++.
Where should I start?
I wanna do Machine Learning related stuff and GUI.
I actually have a browser based application in mind where I'd be needing Artificial Intelligence, cool GUI, etc.
That is a very good question. I think these steps would be the easiest for you -
Install Linux on your laptop or use macOS. I say this because you can develop in windows but it would be much easier on Linux or a mac because of the sheer size of the community.
Get familiar with the command line on Linux/macOS. You should try on Ubuntu which is one of the most popular versions of Linux. You must be able to use commands like - ls, cd, pwd. You can find lots of content for this easily.
Get familiar with the vim text editor.
After writing your first HelloWorld program on C++ using vim, you should learn how to use the g++ command to compile and run your code.
After you are familiar with all of the above, to make your work easier you can download and use text editors like Atom or Sublime.
These were my initial steps in the world of programming. I would also recommend you create an account on Github and browse other open source community projects, also learn git. Lastly explore also other domains and languages like web development, machine learning, python etc. Otherwise, if you are into competitive coding, C++ is indeed an excellent choice. For this, you can visit platforms like CodeChef, Hackerrank, SPOJ etc.
For tutorials, you can find many sites like Udacity, Coursera, edX. MIT OCW is a popular resource on YouTube for formal courses like Algorithms and Data Structures.
PS. Do not waste your time learning everything about everything. Instead, you should keep on experimenting and look up on the web whenever some error or a bug pops up.
Since TurboC++ was just a compiler, maybe you'd be happiest just moving into a full blown IDE(Integrated Development Environment)!
For Mac, I might recommend Eclipse. It's a very popular IDE and can be used for C++.
However, you'll need a compiler. GCC is a good compiler for Mac, but as far as I know you need Apple's "XCode" IDE to install GCC in the first place. So if you were to go through all of that effort you may just want to stick with XCode.
You'd need an Apple Developer login, but here's a tutorial on getting GCC up and running.
https://www.mkyong.com/mac/how-to-install-gcc-compiler-on-mac-os-x/
Of course, nothing is keeping you from sleeping around with some new languages, but if you want to stick to C++ I'd say get your compiler, find an IDE you like and get to learning.
First of all you need to know How compiler works and the program structure.
I recomend you an excelent course called "Programming Paradigms", from Stanford University. You can find it in ITunes University and it is free.
I work in a factory where 80% of our equipment uses an MS-DOS interface. None of our engineers have experience in c/c++ programming, and it was requested we add some features to the machines interface. Our automation group has abandoned the MS-DOS platform in favor of Allen-Bradley controls. I'm feeling ambitious and decided to take on this project, even though I have next to no experience in c/c++.
On to the question:
All of the programming was written and compiled in Turbo C++. I would prefer to use DEV++ for various reasons (ease of use, additional headers, more developed C++ platform, ect.). The problem is the existing programming relies heavily on non-standard headers from TC++. There are 10 or so headers unavailable in DEV++ in the source code, and rewriting the code using more modern constructs is not an option; we would lose what little support we have from our AG, time, ect.
Is there a way I could add all the headers from TC++ to DEV++? For example adding the graphics.h to DEV++ and have it be fully functional? I have tried adding it to the include folder, calling it with #include"graphics.h", and if DEV++ manages to recognize it, it throws a ton of compiling errors because it doesn't recognize the internal commands in the graphics.h file.
Unfortunately I cannot include any example code from this project, due to non-disclosure and copy-write policies.
My programming experience:
DABBLE in RSLogigx500,5000 ; Arduino IDE (don't judge) ; Parker 6K ; PanelView ; ~40hrs of self-taught c and c++.
Any help would be much appreciated.
UPDATE
Very helpful information. It seems like this isn't going to be possible given how outdated the hardware is and the restrictions I have on this project, but thank you all for your input.
Most of the headers from old Turbo C are really just the MSDOS API, in a way. So it doesn't make any sense to attempt to use those headers in any other environment and you can't port them to a Windows compiler. Similarly, graphics.h is for a Borland-specific DOS graphics library called BGI and will not work on any other compiler.
It should be noted that old Turbo C++ (I'm assuming version 3.1?) didn't follow the C or C++ standards much. The C++ version it used is completely antique.
Also note that the Dev C++ IDE is outdated and doesn't update the GCC compiler any longer. The CodeBlocks IDE is a better alternative.
This is more of a "long comment" than a direct answer to your question, trying to guide you to a better understanding of what MAY be your challenge in your project.
I personally would choose a more "professional" level development tool. Either Eclipse (positives is that this is portable and looks/feels the same whether you use Windows or Linux), XCode (works only on Mac) or Visual Studio (which works only on Windows). These are full featured integrated development environments, and they are all very slick. All of them are free or nearly free.
Compiling OLD code, that is written for DOS into a modern compiler with on a modern OS may be quite a challenge, depending on what the application does and how much in the way of assumptions about it's environment the code is written with:
does it assume int is 16 bits
does it call direct to DOS to get file info, opening/reading/writing/closing files
does it do raw keyboard input
does it poke characters and/or pixels directly at the screen
does it use far and near pointers, are there driver-like components that interface directly to hardware interrupts
One thing that stands out in your question is the mention of graphics.h, which I believe is very Borland specific. Which means you'll have to write your own replacement functions - either a replacement graphics.h set of functions (I expect most functionality is available in any modern OS, it's more a case of "what is it called and what do I need in order to call that function"). This can be quite a task in itself.
The tricky part here is not only to identify what the code does, but to replace it with similar logic, that does the same thing in your new environment.
And of course, it all depends on what you want to do with the code, how well written it is - is it nicely modular, does each function do one thing and one thing only, or are there functions that "This calculates the value of , and then reads some data from disk, then does some I/O to the screen, and then talks to some external hardware, and because it gets calls frequently, also updates the time on the screen if it has changed".
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
This may be a really dumb question, but I hope to be able to clearly express myself.
My daughter has a multi-player game source code. For years, she's used Visual C++ to compile the game for Windows. There is a server exe file and a client exe file, which works well if using a Windows server.
What I want to know is, is it possible to compile the server file to use on a linux server and keep the client exe files for windows? Or would there be a compatibility issue?
Thank you.
What I want to know is, is it possible to compile the server file to
use on a linux server and keep the client exe files for windows?
Yes, it's possible. In fact this sort of thing is done all the time. I do it for a living. In order to accomplish this, you must do two things:
Write the code in the first place using only Standard-compliant idioms, syntax and functions. This can also be accomplished by using 3rd party libraries that are compatible with both Windows and Linux, such as Boost.
Compile the code on the target hardware.
Step 2 is arguably the easiest. All you need is access to a linux machine with a linux compiler, such as g++, and let 'er rip. You'll need to set up your own makefiles and such in most cases. Usually a tool such as CMake is used to accomplish this.
Step 1 is much harder. Code that is legitimately compilable on multiple platforms (such as Windows & Linux) is called "portable." Writing portable code is easy enough if you are focused on doing this from the outset. Retrofitting portability, on the other hand, can be a gargantuan task. Many projects are abandoned completely because of this hurdle. If your daughter hasn't been writing portable code from the start, there's a very good chance that making it portable is a near-impossibility.
I'm not trying to dissuade you from the attempt. In fact I'd encourage you to take it on. In my experience, making a platform-specific piece of software portable is one of the harder things for a programmer to do correctly, but even if the project is ultimately a failure the effort reaps its own rewards by making them a better programmer. In order to write portable code one needs to have a fairly solid grasp on the language at a brass-tacks level. Programmers who can write portable code are very often (not always) more skilled than their platform-specific counterparts.
As far as compatibility issues are concerned, the only real 'gotcha' that comes to mind is endianness. Especially in a client/server type system, you'll need to tacke this sooner rather than later.
Hard to say, C++ compilers are hardware specific (as opposed to Java), Your best bet is to try and just compile it on a linux distro C++ editor. See what errors you get and troubleshoot from there...
Good Luck
It depends. I doubt you will be able to port that Windows code directly to Linux and just recompile. The IPC (Inter-process communication) between the server and client is likely written using Windows procedures and would have to be changed for Linux. I'm fairly certain they use different calls for different platforms.
Of course, if you have the source you can make these changes yourself but it will likely require some debugging.
Info on Linux sockets: http://www.linuxhowtos.org/C_C++/socket.htm
Info on Windows sockets: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740673(v=vs.85).aspx
There are several approaches you might take. Each has a unique set of tradeoffs and benefits.
Rewrite the code to compile on Linux using native services. Difficulty +++, benefits +++
Rewrite the code to use a platform-independent library which provides needed services. Difficulty ++, benefits +++
Run the .exe code in a Linux-hosted virtual machine running Windows. Not difficult, benefits ++
Run the .exe on Linux using Wine a compatibility layer which translates Windows calls into Linux equivalents. For many properly written Windows programs, this works quite well. Not difficult, benefits ++
Each of these requires some degree of education either for learning a new programming environment or determining proper configuration and changes in operability. There are plenty of free forums for support for all.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I'm a student and i want make a build tool as a side project for myself because none of the current build tools seem to attract me. There's ant, but i really dislike looking at XML (i don't know why, but i really don't see the appeal of tags; it puts me off visually and cannot be made neat in my eyes). There's maven, but i really don't want to be working on a project just to have it fail all of a sudden (this is based on the research I've done where people say that there are times that maven fails to build all of a sudden. This could just be total BS but i'd rather not find out the hard way), plus there's some XML involved. I really liked make, but it isn't portable, and even though the chances of me using a non-Windows PC are next to nil, I am unfortunately, a computer science student who has been properly trained to always assume the worst case.
Currently, i am looking into Gradle. I'm still trying to figure it out (i am a really slow learner) but i like the syntax. It might also be beneficial to note that i am so shallow that i don't really care about the back end stuff or any of the advanced features cause i don't really understand dependency management and stuff just quite yet. All i care about is that the configuration syntax or make file looks clean, that it works without requiring internet access, absolute paths, or anything of the sort, and that it works consistently and doesn't take too long. I believe that the syntax is important because, like all code, if it looks ugly, you won't want to read it.
I want to make a build tool that is simple, functional, and portable (i'm gonna be running it off my External HDD with Java in it). I'd really appreciate any suggestions this community has to offer, such as "It really is better to just stick with ant or maven cause they work already" or "be sure to avoid make's dependency issue". This will just be a side project so i can work on my Java and maybe learn something new so even if i fail, i still might learn something new so no need to comment on that.
If you haven't already tried it, try Automated Build Studio. We have used if for a couple of years now and it works fine for us.
Another existing tool you might choose to ignore is SCons. It's written in Python and has some very nice features including, possibly relevant to you, easy extensibility.
And yes, I think you are going to crash and burn. Far better to learn one of the existing tools properly than to reinvent this particular wheel. Use your creative urges and time to write something truly new.
Furthermore, and since you are a student allow me to stand on my soap-box: one of the lessons that new entrants to the IT profession have to learn is to use the tools you are given, not to expect to be allowed the time and money to develop a new one. Don't expect to be able to rock up to work on day one and try to make a case for writing 'MyMake' because GNU Make (or whatever) doesn't float your boat.
Here's just an idea:
ant is really not such a bad tool. Maybe you could consider building a front end for it that translates a DSL (Domain Specific Language) of your own design into ant's XML, and hide the XML from your tool's users?
You may also want to take a look at Rake. Someone recently ranted in his blog about how terrible Maven is (and the debate goes on) and he much, much prefers Rake.
I started one, some 7 years ago. I am still using it. No one else uses it. http://gna.org/projects/maker/
I started on some same ground than you: multi platform (was Linux, DEC Alpha, and Windows at the time) with a new shiny lanquage: Python. I was getting ideas from Miller's Recursive Make Considered Harmful in the sense that I had a source file for each executable (same for shared library, or static library) that was listing the C/C++ source files, and dependencies on other libraries. The main feature was to generate on the fly a makefile that is fed into gmake (that does a perfect job, provided it has a perfect makefile) to build all the binaries in one call, managing all the dependencies (with gcc -MD options).
Over time. it evolved mostly into a tool that can use Visual Studio C++ project and solution files to compile on Linux. And I am struggling to keep it up-to-date with new versions of Visual, and new values of project parameters and project properties that my coworkers use.
I wouldn't recommend starting a new tool.
Why would using Maven mean that your build fails "all of a sudden"?
I would advocate always using continuous integration (e.g. cruise control for ant or Hudson for maven) regardless of the build tool you use. This should eliminate a build failing "all of a sudden"
There's maven, but i really don't want to be working on a project just to have it fail all of a sudden.
What does that mean?
Anyway, if you're into Groovy, I recommend Gant.
Cobbling together your own build tool doesn't sound like a great use of your time, especially when established tools such as ant and maven exist and have such vast user bases that are finding (and fixing) bugs with those tools.
I don't understand your comment about maven causing build failure all of a sudden.
XML will haunt you everywhere you go. Invest in an excellent XML visualizer / editor, and go to town with Ant anyhow!
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm looking for a good IDE for C++ that has most or all of the following properties (well, the first 4 or 5 ones are mandatory):
cross-platform (at least Mac, Linux)
of course, syntax highlighting and other basic coding editor functionality
reasonably responsive GUI, not too sluggish on mid-size (say, 100 files) projects (both my Linux and Mac computers are 5 years old)
code completion
integration with gdb
SVN integration would be nice too
refactoring (rename a variable semi-automatically throughout the codebase, etc.)
can display class hierarchy
can add hypertext-style links to the code (so you can click on a function/class name and it brings you to the declaration),
can show code parts that (potentially) call my function (I know that's hard to do for C++ so I added the potentially)
So far, I've been using Emacs for everything, but I think advanced features that give me more overview and search capabilities like the last three would be nice. I'm tired of just using grep and find on my codebase.
Basically, I want most of the things for C++ development that Java IDEs usually do.
I see Netbeans can be used for C++, as well as Eclipse. I think they would fit my requirements. Has anyone actually used them for daily coding? What are the differences? What are your experiences? Code::Blocks is more lightweight and doesn't do many of the things listed above, right?
Note: I don't need a GUI builder.
Update: With the bullet point 10 I mean that I can give it a function name (e.g. Foo::setValue), and it shows me all occurrences where this particular function (and not other functions of the same name, like Bar::setValue) is called in my codebase.
Code::Blocks does the first 5 and it's also got class method browsing (though not a heirarchy display). It's a much more lightweight solition thaen Eclipse or NetBeans, but if you like the minimalist approach it's pretty good.
To summarise CB versus your requirements:
Yes
Yes
Yes
Yes
Yes
No - but you can add it easily
No
No, but similar functionality
No
Can go from definition to decl and vice versa, but no callers list
As all the solutions you mention are free, you could always try them all and then make a decision on which one to stick with. That's what I did.
In addition to the ones mentioned, there's QTCreator, which has "Rapid code navigation tools" though I've not used it.
I think though that the non-essential requirements aren't so good, you can easily see where a method is being called using search! (of course, if you have a huge class hierarchy where every class has the same named method, you've only yourself to blame :) if you havn't laid your classes out in an easily understandable way)
I'd recomend Netbeans, in 6.5, its pretty fast IDE and offers all 10 of your requirements.
I recently asked this same question. I ended up choosing Eclipse with the CDT plugin and the Cygwin libraries. I've been pretty happy with it, except I haven't quite got the hang of the debugger. The window for walking through source on the debug perspective is pretty small, for some reason I haven't figured out how to see into arrays, and I think I knocked out one of the windows for displaying variables and don't know how to get it back. I've ended up abandoning the debugger perspective and just walk through debugs in the normal perspective.
Also, I use Eclipse for Java, so the helped minimize the learning curve. It can do refactoring and you can integrate svn.
Java based IDEs (Netbeans and Eclipse) are sometimes somewhat slow. Also their main focus is Java. One problem with Eclipse is that it is difficult to use for small screens, such as in laptops. I prefer to work usually in vim + ctags (to perform the functions of grep and find), and when I have some advanced operations like comparing two directory hierarchies, I use Eclipse. I've not used Code::Blocks much, but I hear good things about it.
Coming from Emacs, I think you'd prefer something lightweight and not heavy-weight. I would consider Code::Blocks then as a good candidate for exploration.
codeblocks is open source !!
http://www.codeblocks.org/
Go for Eclipse. If you have a decent computer, it is fast enough and has best possibilities with its plug-ins.
codeblocks have a lot of features just check them up !
and it is free !
If you already know Emacs, it may be easier to just start using a few more packages, than learn a whole new IDE.
For example, you can easily do #9 with Emacs: just run tags once and then M-. RET anywhere.
You also have to weigh the IDE's features against what you lose. For example, most IDEs don't tend to have Emacs' easy macro capabilities or numeric prefixes, which are often like a more general form of refactoring.
It is not only the IDE that matters - you would probably need to be able to build you application outside of the IDE (i.e. continuous integration).
Consider using CMake to create a cross-platform description of your build scripts. Once you have the CMake Script (which is straightforward) you can generate from it project files for the IDE of your choice - eclipse, kdevelop, Visual Studio, codeblocks, etc.
I would suggest using eclipse as an IDE. There are few options of how to use CMake with eclipse. Play around, and find the best for you.
Once more - CMake is not only cross-platform it is also cross-IDE. And CMake scripts are very readable, a simple make file would look like this:
project(hello)
add_executable(hello hello.cpp)
Now compare that with makefiles, or setting up a project in your favorite IDE!
My two cents (in no particular order ... and not all these options are c++):
Qt ... my first productive GUI building framework
Lazarus ... what a cool name, and very productive tool (not c++ though)
MonoDevelop ... I'm falling in love with c# development (very much like c++)
Java ... ubiquitous ( a bit like c++)
CHEERS!
Sublime Text Editor is the best cross platform editor so far I have seen. Try using it http://www.sublimetext.com/. It comes with unlimited demo period without suppressing any of its functionality. But if you are satisfied with that, please buy and use it to credit the author.