C++ parsing a text file that is located online - c++

Information about what I want to do:
-read in a few integer variables from a text file that will be located on a dropbox public folder.
-the variables will be used to trigger some if statements thus controlling my application remotely if I need to have it do something ( I would just save the variable I need to that text file and my program with would read from it every 5 seconds would see it and perform the required actions).
-this is a console application which is being built and compiled in visual studio 2010 on windows 7. The software will also be running on a win7 computer.
I need help with:
I already have read on using a library called libcurl. The problem is that I do not know how to link this library with my project in vs2010. Detailed instructions on how to do this on vs 2010 would be very helpful.
OR
if you can think of a better and easier way to accomplish what I need done, offer some advice and direction

It sounds like you're a novice, is that correct? If not then apologies for stating the obvious.
To use your compiled DLL in your application you need to 'add a reference' to it. You can do this by adding what is called a binary reference, where you simply tell visual studio where to find the dll. Or you can add a project reference if the project which is producing the dll is within the same solution. The best approach is to use something called nuget. It's a visual studio extension which automates the adding of binary references available from a public repository.
I have just done a search for libcurl on nuget.org and drew a blank. As I am unfamiliar with this library you may have better luck finding a nuget package as you will be a le to search using better terms that I did (curl and libcurl)
Whatever approach you take, just right-click on the project in which you want to use libcurl within the solution explorer and you should find an add reference option in the menu.

Related

Can I make Visual Studio show a notification or alert when I open a particular project or solution

I would like to perform an action upon opening a particular Visual Studio 15/17/19 solution.
I need to inform anyone who is about to work on the project that there are important notes (included in the project) that they should read first. Ideally it would be a pop up so as to be very obvious.
When googling I can only find solutions that involve Visual Studio extensions but I need something that does not rely on anyone else doing anything (e.g. installing the extension) - it needs to be something dependent only on the project itself.
I'm hoping for something that I can add in the .sln or .scproj file that VS will see when it loads the solution and take action, but anything that achieves the same purpose would be good.
I'd be grateful if someone is able to let me know how I can achieve this.
You've got an extension called Solution Open Pop Up supported on many versions of Visual Studio.
In the Overview tab there is a Features section where you can see a short example of how to use it. From the extension's website:
If a file called SolutionOpenPopUp.txt and/or ReadMe.txt exists in the root folder of the solution, the contents are shown in a pop-up when the solution is open.

new to eclipse and c++: how does a c++ project get deployed?

i am using c++ in eclipse, a project which contains many header files , cpp files...etc when finally done, how does it actually get implemented in the real world once it is done? Does an .exe file get created ? Or how can users install the program on their computers?
Can you share your experience with me ?
Also can you tell me what IDE you use for C++ development ?
I tried to look through some documentation but could not find anything.
When you compile the code, it will output an executable file (.exe) that can then be run from a command line, double-clicked, or put into an installer. The executable files name will be .exe and placed in the output directory as specified in your project settings.
As mentioned, this can be bundled in an installer but that is very likely overkill and way beyond what you want. So long as you have used standard C/C++ libraries that come installed on a user's system, they can just invoke the program from a command line or simply double-click the executable. If your program doesn't have any interface and simply prints messages, then they person will want to run it from the command line. Finally, if you have used other libraries that you need to include with your program, then an installer may be what you need in order to make sure the end user has everything they need to run your program.
As far as IDE's go, I've used both Eclipse and Visual Studio. Visual Studio is better tailored to C/C++ development (this is assuming you are programming on a Windows machine) but has the downside of costing money if you don't get it through your employer or school. If you can get access to it through either of those channels, I would choose it over Eclipse. Eclipse will do what you want and is free, but Visual Studio might be a bit better. Also, if you are going to spend money anyway, I suggest looking a SlickEdit. I use this at work and really like it for C/C++ development.

Read multiple files

I'm new to c++ and am trying to alter the console app code posted below to read multiple files, ideally using a wildcard extension. Can some please give me some pointers..?
http://msdn.microsoft.com/en-us/library/ms916815#odc_wssusageeventlogging_examiningtheusagelogfileformat
-----------Edit-------
What I need is how to change the code above instead of pointing it to a specific [filename.log] point it to a directory name and let it process all the log files in that directory.
--------------Tools-----
Win32 Console Application project in Visual Studio 2010 in C++
[To be run on win 32 bit platform]
Using Win32 APIs you can list the files in a directory by following this example. From there it should be relatively trivial for you to incorporate that code into your application to allow you to process multiple files as requested.
Specifically the FindFirstFile API allows for wildcard when search for files.
If you're willing to use the boost library check out
this post. If you're using something like C++/CLI then there is support in .NET for this as well (I'm assuming for now you're not using C++/CLI). If you specify the tools at your disposal maybe you can get a more directed answer.

C++ Logging Library Setup

I've been trying for about 2 weeks now to get a logging library to work with. I've tried Log4cxx, Log4cpp, log4cplus and boost.log. The problem isn't that none of these work for me, it's that I can't figure out how to get them to work at all. I would really like to use log4cxx since I'm working with log4j/logback at work, but I haven't been able to get any of the libraries based on log4j to build. I've been able to build and use the boost library, but boost.log gives me all kinds of linker errors no matter what I try. If anyone could direct me to a step-by-step guide to get one of these libraries working I would greatly appreciate it. Also, I'm using eclipse as my IDE if that matters.
Did you ever get this working? Log4cxx definitely works on Win7. Maybe you could post some of your build errors. Just guessing, perhaps you didn't configure your eclipse project to link with a log4cxx static lib.
Boost.Log works for me quite well (Linux and Windows). It is not a header only library, there is a compiled part that you need to link against. See instructions here.
It also depends on other, non-header, Boost libraries:
The logging library uses several other Boost libraries that need
building too. These are Boost.Filesystem, Boost.System,
Boost.DateTime, Boost.Thread and Boost.Regex. Refer to their
documentation for detailed instructions on the building procedure.
Depending on your platform there may be pre-built versions of the Boost libraries. Otherwise building it yourself is straightforward if you follow the instructions. If you get stuck update your question with where exactly you got stuck and what you're seeing.
I'd recommend Pantheios. It takes some time to build everything when you first download - type make build test and go have lunch - and you have to select the output streams (Pantheios calls them "back ends") at link time, but for coding, it is really simple, e.g.
std::string name;
int age;
pantheios::log_DEBUG("name=", name, " age=", pantheios::integer(age));
It's designed from the ground up for speed - the age won't be converted into a string unless the "DEBUG" level is switched on - and robustness - which is why you can't pass fundamental types directly, and use "inserters" (e.g. pantheios::integer). See this recent blog post by Pantheios' author for more information.
I managed to get log4cxx to work, this was done in Visual Studios 2013 running on Windows 7 OS.
This following is what I did, step by step:
Download the log4cxx ZIP package extract its contents, http://logging.apache.org/log4cxx/download.html
Download apr and apr-util ZIP packages, http://apr.apache.org/download.cgi
Then
manually extract this zip apr-1.2.11-win32-src.zip (the
extracted folder should be named 'apr', if it is not manually rename
it)
manually extract this zip apr-util-1.2.10-win32-src.zip (the
extracted folder should be named 'apr-util', if it is not manually
rename it)
open a command prompt and run the following: cd
apache-log4cxx-0.10.0 configure (this
will execute configure.bat)
We will need to disable to use of the APR ICONV and LDAP support.
In order to do so, we will append the following files manually:
Open apr-util\include\apu.hw. Find the line starting with “#define
APU_HAVE_APR_ICONV”. Change the value to 0 and save.
Open apr-util\include\apr_ldap.hw. Find the line starting with
“#define APR_HAS_LDAP” Change the value to 0 and save.
We need to build the log4cxx.dll, to do so convert *.dsw
to *.cxproj.
Launch Visual Studio 2013 and open log4cxx.dsw.
VS will ask if you like to convert everything. Simply click Yes.
There may be some warnings in the migration report, but nothing that
should prevent the solution from opening.
> The projects xml, apr, and apr-util should build successfully.
If you try compiling the log4cxx project it will most
likely fail with hundreds of errors. This is due to a bug in VC++
which can be worked around.
Move all macros outside (above) the class they are in.
LOG4CXX_LIST_DEF macro is used to define classes. All macros reported in error C2252 will need to move out of any classes. This
may also include moving definitions which are used in the macro.
Next, change all LoggingEvent::KeySet to KeySet (this is no longer nested in a parent class)
> Following this, the log4cxx project should now compile
successfully on your machine.

Setting file version number in Visual Studio 2005 C++

Can anyone point me in the right direction how to configure Visual Studio 2005 with our C++ console project how we can include a 'File Version' in the details section of the file properties.
I've tried resource files without any luck. This is with a C++ project just for clarification, and big thank you for the guys you responded with C# suggestions.
Thanks in advance.
If you are talking about unmanaged c++, you need to add a version resource to the project.
right-click on the project, choose add - Resource.... Choose Version and press new.
There you can enter all info you need.
You have to have one VS_VERSION_INFO section in your resource (*.rc) file(s) that compile into your project.
In the Visual Studio 2005 Solution Explorer, open the context menu on your C++ project and choose Add, Resource.
Mark Version and click "New".
Fill in the fields as desired and save the file.
Build.
Now your project output has a FileInfo resource.
Please be aware that Windows Vista does not show all available version info in the Explorer context menu's "Details" tab.
For c++ projects I use StampVer and call it as a post build operation including check in/out of revision control for release builds.
Unless you have a good reason for your file version to be different than the version of the assembly inside, I think it is a better idea to provide the AssemblyVersion alone. If you do not specify an AssemblyFileVersion, it will automatically get the same value, so you can see your assembly's version directly in the file's properties.
The advantage is that you can use a wildcard and allow the version to be automatically incremented, so that every time you compile the library you get a different build and/or revision number. As far as I can tell, this trick does not work with AssemblyFileVersion, so you have to increment it by hand.
Of course, all this only applies if you're writing .NET code. Are you by any chance talking about a project using unmanaged code?