Add curses library to Visual Studio C++? - c++

I'm trying to use the curses library on Microsoft's Visual Studio C++. I downloaded ncurses-5.9.tar.gz from http://www.gnu.org/software/ncurses/, and I unzipped the file. However, I can't find a .lib or a .dll file in the package. Without the .lib file, I don't know how to link my code in Visual Studio to the header files in the ncurses package. Do I need to move the header files to somewhere in my project?
Thanks for the help!

In a nutshell: you want Bill Gray's PDCurses. That fork is quite active. The "original" implementation is in
Bill McBrine's repo, with some activity going on. The two projects seem sadly to have diverged, though. The former has implemented a native Win32a GDI terminal window, while the latter only supports the native Windows console.
What you did is not how to use curses at all. What you have downloaded is source code, there are no binaries there at all - no .lib nor .dll files for any architecture. Not only that, but the source code can't be directly compiled either -- if you'd have added it to a C/C++ project, even on a Unix box, it wouldn't compile.
In order to compile, curses needs to have a configure script run, that generates some files, probably config.h, perhaps other source files, and makefiles.
Alas, all that is a moot point because curses is AFAIK a Unix library that really depends on Unix APIs being present. Any Windows ports are completely separate efforts.
See also Is ncurses available for windows?.

Related

How to build Visual Studio Solution under Linux?

I was always using Windows, have very limited Linux experience.
My Visual Studio solution contains 5 C++ projects - 4 of them are static libs, and one is main application (that use these static libs), I want to move it to Ubuntu.
I do not use any windows specific code, so with minor changes I should be abble to compile under Linux.
How to do this? What exactly software should I use under Linux? What should I do with static libs, should I keep using static libs in Linux? How to convert Visual Studio solution to something Linux-like?
upd what if I just download Eclipse in Linux and then file by file, project by project, recreate and copy everything from VC++ to Eclipse? this should work, isn't it? I have just 100-200 files so it's possible to do this by hand.
I can think of two reasonable options. The first one is to create a makefile that will compile everything for you. There was once a utility called Make It So that did this automatically. Their page specifies compatibility with Visual Studio 2010, it might work with Visual Studio 2012 as well.
You can also use cmake. It's a bit more involving to get right, but the end result will be the ability to compile your code more or less anywhere.
Use xbuild? So if you install Mono, then you have xbuild which is the OSS version of msbuild. You can just build your .sln file by something like "xbuild solution.sln"
Clion can generate cmake file automatically for .sln project under linux.
If your code is not dependant on any Window specific library then you can use make the utility to make any lib, bin.
You can also provide different rules to link your library based on your specific requirement. You can also link third party library using Make utility.

How to generate vcproj files?

Suppose I've got a cross-platform C++ library, let's call it ylib. My primary development platform is Linux. I'd like ylib to be buildable by MSVC (2008, 2010, 11, etc).
What's the best way to do this? Do I generate .vcproj files? If so, how? Ideally I'd be able to generate them without using Windows myself. No extra dependencies should be required for Windows.
Multiple variants should be build: debug dll, debug lib, release dll, release lib with dynamic runtime and release lib with static runtime.
You could use cmake for your build scripts. Cmake has the ability to generate visual studio project files from the cmake build scripts. So you'd just need to distribute your cmake files, then individual people using windows could generate MSVC project files from that.
Though as pointed out in the comments, it'd be difficult to guarantee that you could actually build your project under visual studio without trying it out yourself.
EDIT: Though I've just realized that you requested no extra dependencies on linux, which this would not solve. Unless you generated the vcproj files yourself using cmake, and distributed them. But personally I think it'd be better to just have the cmake dependency. It's freely available, and easy to install.
This also has the advantage of supporting whatever version of visual studio your end user happens to have, without the need for distributing several different formats.
You just need to understand the format of vcproj files and then write them - they are simply XML.
I don't know how well MSFT document the settings (not very if history is a guide) - so for simple projects I would just create a project in MSVC and look at what it writes.
Alternatively you could just use cmake which already does this.

LEDA library installation

I have downloaded LEDA free edition from this website
http://www.algorithmic-solutions.com/leda/ledak/index.htm
First quetion:
I want to use this library with my project in VS2010 ide, but i didn't really catch from installation notes, how can i install this library on windows platform.
There were already some static libs (you can see them on the image), which i added to my project with appropriate headers. But that, i suggest, is not a right way. So i will be glad if you will briefly describe the steps, which i should make to compile this library...
The root library directory looks like this
Second question:
In leda's installation guide i can see two main sections:
1.) CONFIGURATION/INSTALLATION FOR UNIX
2.) CONFIGURATION/INSTALLATION for MS Visual C++
In "CONFIGURATION/INSTALLATION for MS Visual C++" i can see the following:
Go to the LEDA main directory (at the command prompt used above).
Type: lconfig msc [dll] [ ml | mld | md | mdd | mt | mtd ]
I'am sorry, i have never seriously used UNIX based systems, but i always thought that MS Visual C++ is a thing, strongly connected with Windows, and lconfig is a unix command?
So i confused, this guide is for unix or for windows or ...?
Thank you, sorry for possibly stupid questions.
The LEDA "free" edition does not include source code. They sell the source code for users who want to modify / compile it. What you have downloaded can be used by including the .h in \incl and linking against the appropriate .lib files. It appears that the package gives you several .lib files to cover all the options of static linking or dynamic linking.
The lconfig instructions are for when you do have the source code, and you want to control which configuration of dll/lib gets built.
"lconfig" is not a standard or even niche UNIX tool; a quick google suggests it's something that actually comes with LEDA itself. Since you've downloaded it, you ought to see it someplace in the bundle.

Setting up midiIO library on Windows

I've downloaded the midiIO library and in the readme it says:
edit the file Makefile.library and set the OSTYPE and OSSUBTYPE to match your hardware/os setup.
type "make library" to compile the library. It will be created as lib/libmidiio.a in unix.
edit the file Makefile.examples and set the OSTYPE and OSSUBTYPE to match your hardware/os setup.
Also, if you are using ALSA, then uncomment out the POSTFLAG to use the alsa library (-lasound).
type "make examples" to compile the example programs in the examples directory. The example programs will be place in the bin directory.
1 + 3 are fine but 2 + 4 are over my head. I've worked in a unix environment before and have used gcc with flags but I need to get this done in Windows. I typically use Visual Studio but don't know how to achieve this with that.. I've downloaded Dev-C++ if that's any use but I don't know what to do with the makefiles?
Ignore the makefiles and set up a fresh project in Visual C++. Make your target a static library (which will be a .lib file in Win32, not a .a file as in unix as you probably know). It is unlikely that the project will build out of the box, so you might have to deal with some compilation errors relating to unix-specific symbols. I took a quick look at the source code, and it looks fairly well-written, so I don't think you should have many problems building it directly in Windows.
Alternately, you could build the source using the real make tool in cygwin, but this means that you would need to distribute the cygwin library with your final product. This may or may not be more trouble than it's worth, especially if you are already using VC++ for the rest of your project's code.

C++ shift from Unix to Visual Studio in Windows

I am a professional working for a software firm.In my past company basically i was working on C & C++ on unix.Now i suddenly shifted to C++ on Windows and i feel like i am in a completely different world.Basically i am working on a very big application which was totally written in C++.To keep it simple ,i dont have the source code .I have the exe of the application and several other dependent files.it is a GUI application(several windows,reports,graphs and huge mathematical calculations are done by this application).Now i finally have the source code of the application which includes some headers,some vcproj files,some dsw files and several other which i dont even understand why the hell are they present.
Now as i C++ programmer my responsibility is to make all the BUGS that the clients identify replicate and fix them.
If its a bug on unix i can simply use the binary and source code and run gdb/dbx and find out the issue in some or other way like adding adding some printf statements.
But given the files i mentioned above.how could istart debugging an application in VC++ in VISUAL STUDIO.
Is it very difficult for a C++ programmer to shift from Unix to Windows.
Is ther any good resource which i could refer for this kind of change where i could grasp things quickly?
given the exe and the source code of the application how can i start debugging a program by running the application in VS C++-(BTW i am using VS 2005)
The main difference is that on Unix, you'll have Makefiles, which you won't find on Windows. Visual Studio organizes your code in projects and solutions, and those project files contain all the information VS needs to compile&link your projects.
If you have a *.sln file, just double click it to open it in VS. Then build the source (usually by pressing F6) and run in debug mode (usually F5).
More details:
A project is a collection of source files that result in 'something', usually a LIB, a DLL or an EXE.
A solution is a collection of projects. Useful when e.g. one project creates a LIB that is used by another project. When you set dependencies between projects, VS will build the projects in the right order.
Extensions used:
*.vcproj : Project file for C/C++ sources
*.vcproj..user : contains which windows are open in the GUI.
Can safely be deleted.
*.sln : Solution file
*.ncb : Intellisense database for a solution. Can safely be deleted.
*.suo : contains which windows are open in the GUI. Can safely be deleted.
*.dsw : Visual Studio 6.0 related file - not used in VS2005. (Replaced by *.sln IIRC)
./Debug/* : folder with all
intermediate files for a Debug build
(can be changed)
./Release/* : folder with all
intermediate files for a Release
build (can be changed)
That's all I can think of at the moment.
If you only have a .DSW file and not a .SLN file, then it means that the project was probably last worked on with VC6 and not one of the later Visual Studio versions.
That's a shame, because there have been lots of changes to the C++ compiler since VC6, and you're probably going to find the project doesn't compile with VS2005 without needing some minor changes to source code.
Do you have a .SLN file - if so, what's the version number at the top of the file (it's a text file)? If you don't have a .SLN file, can you get hold of VC6?
I would always try to get stuff going on an unfamiliar platform with the best matching tools, before I tried to bring it forward to later versions.
I understand your pain; I took the same path a few months ago.
You probably figured it out, but Visual Studio is not the exact alternative of gcc/g++. It embeds a text editor, a debugger, and so on.
Usually, you have two compilation "modes", debug and release. (you can add your own)
When in debug mode, all optimization are disabled and you can execute your program in the debugger, use step by step, add breakpoints, ...
Just start it using the F5 key.
More notes on the additional files:
In the Visual Studio world, .vcproj files represents "projects": a bunch of file that belongs to the same project (source files, headers, resources, ...).
A .dsw (old name for current .sln files I believe) is a "solution" file: a group of one or several projects which can have internal dependencies. Example: you can have in the same solution, a library and a software that depends on it. So that when you compile the whole solution, things are built in the correct order.
First thing you should try is to attach to the process while it's running (Ctr-Alt-P and select the process) if you have the .pdb (debug information) files you should be able to debug the process without re-building it.
If that fails try to un-check the "Require source files to exactly match the original version" option in Tools -> Options -> Debugging.
If that too fails you'll have to build the application again (by opening the .sln file and performing a build) so that the binary matches your source files.
Good luck.
Compile the code with debug info and press f5 (Start Debugging). I don't see where is the problem. On linux is sort of the same.
VS2005 can convert the dsw file for you to a sln file, but you need all of the original VC6 files in order for the conversion to be successful. For debugging please check out following msdn link, I hope this will help you.
http://msdn.microsoft.com/en-us/library/sc65sadd.aspx
Please select hyperlink "Debugging Native Code" for C++ specific.