Import a library to Visual C++ - c++

I have some experience with C#/Java, PHP, ASP and all the other web based fuss languages but recently I've been trying to learn the real deal, which to me is C++. I must admit syntax is a bit weird to me, coming from managed environments but I started managing it. I bought some books but most of their examples, which I do understand, but they doesn't really help with the IDE, of course not, since they're not specialized about that.
So either way, I decided I've had enough with theory and simple book jobs so I came up with a "project" to test myself. I thought to myself that It should have some sort of INI parser, but I didn't want to write one myself, the "task" was to implement a 3rd party library/solution. Now from visual studio for C# I know how to add shared DLLs, which is not the problem. After some digging I've found this
http://code.jellycan.com/simpleini/
Cool thing about it is that it is claimed to be cross-platform which should be a win/win. It's open source as well, which is great.
But the question is, how I add it to visual studio so that when I include SimpleINI.h my IDE would compile it as well on each build. One way is to have it compiled as a shared DLL, I think, but I don't really want that :< . I really like the idea of open source and I imagine myself throwing code out there in the wild, in the future and I would like to include all the sources including the libraries, with proper credit.
How do you guys do it? I'd appreciate if you suggest a book or are "step-by-step" guide.

Related

Reading/manipulating images in C++

I am a frustrated newbie of C++ who would like to do the simple task of extracting a pixel matrix from an image file, do some transformation, and then output the modified matrix to an image format of my choosing.
I've given libpng a try and it's API is a mess and hardly readable. Interestingly, some people said it's the best available for C++. I gave my software developer cousin a call and he told me to use OpenGL. So, I did some Googling and I still haven't found a straight answer.
It appears getting a simple "int* readPNG(char* path)" is too much to ask for when the likes of Java, Matlab, and python have these things included in their standard libraries. This is just ridiculous! How do you pros come by and what libraries do you use?
Also a few trivial C++ questions:
- Is there any way to organize classes in a hierarchy like how packages are used in Java? I tried filters in Visual C++ but they don't seem to be the same thing.
- Is there any way to get easily comprehensible stack traces for runtime failures?
Try OpenCV. It is an image processing library with very simple features for editing and saving the images. It will serve your purpose. It also comes with very elegant documentation.
I've found ImageMagick's Magick++ library to be the most useful tool for handling image formatted data programmatically.
C++ has namespaces like Java but they are much more difficult to use and may only make things less readable. As for stack traces, I recommend combing the existing stackoverflow answers for that. In short, it's not simple.
I suggest you improve your Google-fu. There are lots of image processing libraries for C++, including the Boost Generic Image Library, which is as close to standard as you'll get. If you don't have Boost installed and minimal fuss installing libraries, you can always try The CImg Library.
As for your other questions (e.g. stack traces), you'll need to ask separate questions.
I'd suggest Magick++, the C++ API to ImageMagick.
As for packages: you can use namespaces, but that's not nearly comparable to Java's packages (no package-level access etc). They're mostly what they're called: a means to organize names.
Stack traces are not trivial in C++. And there's no platform-independent way of implementing them that I'm aware of.
If you need these features, I just wonder why you don't stick with Java or Python or the likes ? ...
1) Try freeImage - very easy to use and the documentation is readable.
freeimage site
2) for stack traces: which environment are you working with? In Visual Studio there is Stack window (Debug/Windows/Call Stack - Alt 7),
You can also use DebugView and OutputDebugString - not really traces the stack, but can be very usable in debugging. .
I recommend DevIL (formerly known as OpenIL). It has read and write support for 17 formats, and supports many more for just reading.
This is my answer to my very own question here:
Some of the suggested libraries up there have issues with installation with Visual Studio 2010, offer practically no instructions for installation with Visual Studio (i.e. FreeImage), or simply have ridiculously messy API's (i.e. libpng).
If you are new to C/C++, please be careful about what library to choose. Even if there are technical forums roaming with gurus who knows all the answers, you are most likely on your own spending days experimenting and piecing up clues that experienced volunteers could've easily answered in 2 sentences (if they bothered).
Now, what works for me is the OpenCV image library (http://opencv.willowgarage.com/), which is introduced by Mister daerty0153 up there. When you go on the website, don't download the superpack from sourceforge. Instead, read the installation instructions (http://opencv.willowgarage.com/wiki/InstallGuide) and choose what platform you are using.
In my case, I use Visual Studio 2010 as my IDE and so this is the actual subpage that is relevant: http://opencv.willowgarage.com/wiki/VisualC%2B%2B
One problem I encountered is letting VS2010 recognize the .dll files and is not remedied by following those instructions. My solution was to copy all of them to my project folder and that solves all the problem. Some suggested it is a VS 2010 bug.
Hope it helps others suffering from the same situation.

C++ Programming tools

My teacher recommended us to use notepad++ and cygwin for our programming needs. Are there any better solutions anyone can recommend out there to program and compile?
Myriad of various IDE's.... Eclipse CDT, Visual Studio Express, Code::Blocks, DevCPP....
And yes, Notepad++ and Cygwin with gcc would be a very viable option if you only need to compile single files for your homework.
Use a IDE
An integrated development environment (IDE) (also known as integrated design environment, integrated debugging environment or interactive development environment) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of:
a source code editor
a compiler and/or an interpreter
build automation tools
a debugger
A few of them to choose from
http://netbeans.org/index.html
http://www.codeblocks.org/
http://www.eclipse.org/cdt/
In my opinion, a very important tool for beginners is a debugger. A lot of question can be answered by yourself if you have a look into the debugger. You can use the gdb but it is hard to use and understand for beginners. So I would recommend to use Visual C++ 2010 Express which has an excellent and easy to use debugger.
Disclaimer:
The following are personal opinions, related to my personal taste on
the subject. Anyone in the programmer community has its own taste and
preferences an can agree or not. Here I just want to tell you about
some rationals. Consider products and related names as "examples."
My Answer
There are mainly three ways to write code:
The manual one
The assisted one
The automated one.
Think to them as:
Driving your car alone
Driving with a navigator
Driving with an autopilot.
Here "driving alone" means "use a generic text editor, a command-line based compiler and a command-line based debugger. The editor may eventually have a clue about the language syntax (thus differentiating different language structural elements, like keyword, literals, operators etc.) but knowing really nothing about what you are coding.
This is what notepad++ does. It makes coding harder, but for very simple things makes you really learn how to "drive".
A "navigator" is a basic IDE like Devc++, or like CodeBlocks: they have the notion of "project", manage the relation between files and manage the invocation of the compiler and debugger, managing the mapping on their output respect to your sources.
You write your own code, but the "road to compile" is told by the "navigator" you have to trust.
An "autopilot" is a more complex IDE (like VisualStudio, Netbeans, Eclipse ...) that can also "manage the code" providing code analysis for either syntax and semantics, context sensitive auto-completion, code generation for common tasks.
They can give you some code you have to complete and connect together.
They make you faster in producing code, testing it, debugging it, but you must have more trust in them or know how they "suggest".
They can be productive, but you have to "configure" them to suite your needs.
Now: since everything is a matter of "trust", and you cannot trust what you don't know yet, and is a matter of "knowing yuur needs" (but a learner may not yet have an idea abut them)
starting with "beasts" like VisualStudio (that mess arout 50% of your computer registry, pretend you to download GIGABYTES from the Internet and installs GIGABYTES of whatever MS library) is clueless: before you will start using all of that, will take years, and VS itself will be changed 2 or three times) or Eclipse (that has the more powerful syntax and semantic analizer, but requires lot of "arcane configuration" you don't even know since you didn't make the first step in programming) may be an excess. At least until your programs will stay in a couple of pages.
starting win notepad++ and GCC (or Mingw) is just a matter of dowload few megabytes, set a PATH, and you go. Fastest way to turn the key on.
when things become more complex, and require some help in organize them, simple IDE like CodeBloks or Codelite are more than effective at "to the point". I will avoid Dev-C++: it's OLD, and doesn't support the "state of art of the C++ language". You an live with them for all your scolarity
when going to more professional kind of projects, and your experience in "using tools" is better, things like Eclipse, or NetBeans may become more "effective". I will in any case avoid VisualStudio: it's not that "effective". But it is the best to develop in Microsoft environments producing MS oriented applications, especially in the ".Net" world. Something you will not see before 2/3 years of experience.
If you're learning you can download VStudio Express. I believe it's free. Easier to use than notepad and cygwin. This isn't a biased opinion. I'm a Linux C++ developer most days but acknowledge the fact that it might be easier to learn using VStudio.
If you are using linux, you can use kate and g++ for editing and compiling c++ files.
If you are using windows, I think your teacher's recommendations are good. Althought there are various IDE's for C++, it is better to use a simple editor that doesn't have code completion and compilation feature while learning a programming language for the first time. IDE's are nice but not good for learners I think.
It's probably a good idea to go with your teacher's suggestion, since you might also need some help in the future, either from him or your colleagues. Another advantage is that, being in school, you'll probably develop using more than one programming language. Notepad++ has support for almost everything you can think of, so you can use it not only for this course. That way you'll have an advantage because you'll learn shortcuts, etc...
If you plan on doing a lot of programming in the future, I highly recommend putting the effort into learning VIM. Nothing else can touch it in terms of speed and power. It has built-in shell access and it is programmable. It is like having God in your text editor. The major down-side is the steep learning curve.
Also, you want to use Git in-case you screw-up and want to go back to a previous point. It lets you periodically check-point your code so you can always go back. For example, maybe you delete something, then later on decide you want to use that code after all. If you've been check-pointing with Git, you can get it back.
Graphical differs sometimes come in handy too.
I started coding in C++ using Turbo C++(the default program available on college computers, I told them it was prehistoric), but then I found Visual Studio Express and never looked back since that day.
Also since i could not install Visual Studio on College computers, I put a portable version of DevC++ on my pen drive to use there.
Eventually I got the College to install Visual Studio Express editions on all Lab Computers (Once I managed to convince them that it was free with no Licensing issues)
For a beginner, go with a text editor and a compiler. Helps you in understanding what actually goes on.
You could use Dev-C++, which is a good compiler for C and C++, if you want lightweight.
Otherwise Visual Studio probably.

what after the basic c++?

i studied basics of c++ in college, we used the book object oriented programming in c++ by robert lafore.
i studied till pointers (almost half the book) and i still feel outdated using the console and not doing something other than that (forgive me for my ignorance) i want to do windows simple apps and knowing how to employ the little i learned.
the problem is when i open a win32 project in Visual studio for example it opens a lot of stuffs and many .cpp's and .h's .
is there a way to comprehend that and walking on the right path?
the code is complicated to me and mind teasing is it suppose to be like this ?intended to be like this for beginners ? is there a reliable tutorial to introduce me to that or do i need to learn the advanced concepts of c++ like templates and virtual functions and file i\o or they are not necessery ?
thank you.
There are simpler languages to learn programming in then C++, and less complicated concepts to be mastered in simple CLI applications. In fact, using C++ to write GUI software is probably one of the hardest things to learn to do well. If you are intent on learning only visual programming, and only in C++, then I suggest trying the programming toolkit QT (http://developer.qt.nokia.com/resources/getting_started/) as you will have a window on the screen faster and more logically then nearly anything else.
Otherwise, pick nearly any interpreted (VB, Python, Ruby) or quasi-compiled (Perl, Java, C#) language and work through a command line tutorial first, as your progress will be much more likely.
Create an empty project in Visual Studio, then it won't create a bunch of .cpp and .h files that you don't care about.
After that, to learn how to write a windows application from scratch, read Programming Windows by Charles Petzold, or google a windows programming tutorial on the web.
Later, get books by Jeff Richter (Windows via C/C++) to learn more advanced windows programming concepts.
win32/Visual Studio is not a good way to learn GUI programming --Visual Studio generates too many mysterious and unreadable pieces of code and the win32 API is a C API which carries a lot baggage from from the early versions of windows.
It would be much better to use a more organised and conceptualy cleaner framework like Qt or WxWidgets to learn GUI programming.
I would actually recommend you use wxPython to learn the basics of wX and switch to the c++ interface when you have a good understanding of the widgets etc.
Most of the c++ code you need for a GUI is just boiler plate property setting and exception handling which wont teach you much and is pretty tedious.
My tip on getting a hang of windows programming:
Read The Forgers tutorial.
Instead of choosing a project with stuff in it, just choose a blank project and start from scratch, it's actually not that hard once you get the hang of it. However, a basic Win32 program consists of approximately 70-100 lines, because:
You have to set up a unique window (this includes registering your window in Windows and creating it correctly)
You have to handle all the messages that are sent to your window
You have to react to the messages that are sent to your window
Especially check out the Simple Window that TheForger created, then start fideling with the flags (dwExStyle and dwStyle) in CreateWindowEx, check out the wndProc function and see what the messages are (I think the most interesting you should focus on is WM_CREATE, WM_PAINT and WM_SIZE). Hopefully, after some time you will get a feel for what everything is and how it interacts.
It takes some time but I guess most stuff in programming does if you want to learn it. When you have your basic knowledge of a window, you should probably see how you should move on, if you should start with 3D (DirectX or OpenGL) or stay with 2D (GDI+). Or take up Qt like suggested by James Anderson, it really depends on what you want to do. But I do think that you should take that decision then and not now. StackOverflow will most likely assist if you ask what direction you should take if you know what kind of a project you want to do.
You need to start somewhere. So yes, you need to learn all those things you mentioned and then some. The then some includes writing console apps until you really understand whats going on. The only reason I can speak is because I am in a similar boat. I would say, from the sound of it, that I am probably more "advanced" than you and I still find doing some assignments/projects in the console challenging.
The problem is: Windows and stuff is complicated, you have all these events (clicks, keys, mouse stuff etc) and you are interacting heavily with the operating system. It is good that you start with console apps, because there you can focus on the actual programming, i.e., learning how to use loops, functions, classes etc.
To learn how to make windows, you should absolutely understand what classes are and how to use them, because in my opinion, all window toolkits worth learning make use of classes.
So, how does this windows stuff work? The good news: A lot of work has already been done. No need for you to re-program a "print file"-dialogue, no need to hand-draw windows with their symbols and menus etc. This is all readily available in so-called frameworks, and there is a bunch of them out there. You can use the Microsoft Foundation Classes (MFC), or Nokia's Qt or wxWidgets etc.
Google for tutorials on these, and this should get you on the way. First look around which framework looks best to you and then do the Hello World examples.
Once you gain some experience, you'll see that it isn't THAT scary. The only scary thing is the unknown that is yet to be conquered.
(A more gentle introduction would be to first do Java/Swing as I find this VERY easy, but the C++ alternatives aren't too hard, really)
Just play around visual studio if you want to get familiar with Visual studio or any IDE. VS does lots of things on behalf of you. Its interactive, select one option, look into auto generated files .h or .cpp, compile it. If you get any error google it. I myself learned this way.
For learning C++ lafore is good book to start with. The most important way of learning any language is writing lots of code. Dont get tempted to look solution in book. The best way is:
a) Read the problem properly
b) Write your logic on paper first
c) Identify interfaces
d) Convert your logic into programme
e) Compile it
f) remove the errors
g) remove all the warnings

Is it necessary to learn Java for contributing to an open source project?

I am more into C/C++. But many of my seniors here in college ask me to learn Java if I want to contribute to an open source project.. I'm in dilemma. what to do? Can't we do a design project in C/C++?
There are plenty of open source C and C++ projects - as well as loads in virtually any other language you can come up with.
Of course it's never a bad idea to learn another language, but don't feel too constrained by "only" knowing C and C++.
If you want to contribute to a specific open source project which is written in Java, of course, that's a different matter... but if you're trying to find C and C++ open source projects, some of the major hosting sites support querying by project language, I believe. For example, you can look at Google Code C++ projects and SourceForge projects tagged C++.
is it necessary to learn java for contributing to an open source project?
#: No
what to do??
#: Do whatever you are passionate with
Can't we do a design project in c/c++??
#: Of course you can, lots of non-java projects out there
Select an interesting C or C++ project and contribute to it. For example look at Tortoise SVN - it's in Visual C++, it's widely used, it's actively developed and its authors accept any useful contributions.
Not unless you want to participate in a Java project, and then again, you can learn it pretty quick if you know C++.
It would only be necessary to learn java if the open-source project you want to contribute is in java. There are so many open-source projects in c/c++ as well. The great example is Linux
If you are good at c/C++ there are plenty of OS projects in c/c++.
They are also fair amount of project in Dot Net and c#.
Contribute where you are strong...
It up to you in which domain you would like to be an expert, so select an open source project based on your interests and start contributing to that domain which would definitely help you in future.
You should also have the fundamental knowledge of other technologies so to learn a new thing is always good.
It up to you in which domain you would like to be an expert, so select an open source project based on your interests and start contributing to that domain which would definitely help you in future.
You should also have the fundamental knowledge of other technologies so to learn a new thing is always good.
Yes, you could contribute in areas like documentation/setup/deployment issues if not.

Does anyone have experience with Clipsmm?

I have been looking at using CLIPS as an expert system for a simulator i am working on, and so i had a look at clipsmm. The only problem is that their sourceforge page has broken links and private forums.
I was just curious if anyone has had experience with clipsmm (i have learnt how to use CLIPS as a stand alone already), and i just need a little help getting the c++ wrapper working.
Any help that someone could give me would be great.
Thanks
-Craig
(sorry can't make custom tags for this so had to use generic ones)
mm is "minus minus", the standard trope for a C++ "founding" pkg (as in eg c-- itself). This is on the one hand in cognitive dissonance with its failure to be just standard C++ with no external dependencies and on the other hand consonant with its use of glibmm. It's vacuous and these dependencies are a major hassle, but I don't know of anything better for C++ encapsulation of CLIPS.
Well, I don't have direct experience, but I happen to have been the original author of a very similar set of wrappers for Ada.
I developed what I needed for a school project, and released it to the Public Domain in hopes that somebody else could build on it or find it useful. Some folks have used it, but not enough to support a full-fledged project. It looks like the userbase in the C++ realm isn't a lot better.
My suggestion to you would be to accquaint yourself with how your C++ compiler handles C bindings, download what code you can find, and dive right into it. You aren't likely to find a lot of very experienced help in a small niche like this.
If I'm wrong, I'm happy for you.