I am new to WebRTC, and I started with installing the ready-to-use library package available at Sourcey.
Using VS2017 I created a simple "hello world" console application which includes one of the webrtc native API headers.
I added the additional include path (Project config > C++ > general > add. include) and link path (Project config > Linker > add. library path).
But I got a lot of compile errors: from them I dreived that the Windows platform was not recognised, and it tried to include Unix* Headers like instead. So first fix was to add WEBRTC_WIN to the preprocessor symbols.
Still I got many (1076) other errors, mostly dubious, e.g. complaining about '::' in std::numeric_limits<int>::max() .
Second fix: I added #define NOMINMAX in my source file. It seems that Windows usually defines macros min() and max() which corrupt the c++ code.
So now 2 errors, complaining about _vsnwprintf() function maybe being not safe. As it recommended I set _CRT_SECURE_NO_WARNINGS but had to do this in the project configuration, it was not enough to set it in the source file including!
Lack of documentation on these problems with the native WebRTC libs is really annoying! Also not in the forum Google discuss webrtc. More user experiences? Tipps?
Edit: I found a nice tutorial which discourages directly using Native API and instead recommends using QT Wrapper: Tutorial
Related
I am trying to get Google Or-tools to work, I followed this tutorial to install it: https://developers.google.com/optimization/install/cpp/windows.
After running the tools\make test.cc, I created new C++ project, added includes of the library to C/C++ additional includes. When I try to build/run I got errors like these: https://i.imgur.com/0VuWNcg.png.
I have win7 64bit and MSVC 2019 so it is a bit different than theirs configuration but this does not seem to be connected.
The identifier errors look like this: https://i.imgur.com/B4YMqM9.png
The error in optional_boolean looks like this: https://i.imgur.com/Wr2l1Xv.png
Does anybody knows what is happening? Does their code have errors or am I doing something wrong?
(I also tried to compile directly from the source but bumped into different problems...)
You changed the includes, but did you change the libraries to link with.
Anyway, you should have a look at:
https://github.com/google/or-tools/issues/1449
I finally managed to get it working. The problem was faulty distribution of google or-tools. At least the problem was with library used by or-tools while using MSVC - it can be some sort of mutual incompatibility, I really don't know, but still they couldn't have tested it and I don't understand how that can happen and get into release).
Steps to solution were these:
Grab this version of or-tools:
https://github.com/google/or-tools/releases/tag/v6.10
Extract it where you wish to have it.
A If creating completely new project:
Grab this (thanks to #Laurent): https://github.com/philippe3263/ORTools_Visual_Studio
Reconfigure include path, lib path and in Linker->All Options remove/delete Additional Options.
B If editing existing project:
Set x64 debug profile.
add include and lib paths.
Add ortools.lib to extra libraries.
Add preprocessor directives _WINDOWS NOMINMAX USE_CBC USE_CLP USE_BOP USE_GLOP
It's possible that other settings are necessary like C/C++ -> Code generation -> Runtime library to /MD but since I already had a lot of custom settings I can't tell what is needed. (but checking the link and going through those settings can help)
Tested on Win7 64bit with VS 2019
I'm a beginner when it comes to c++ and overall including libraries, so I spent the good part of my last 3 days trying to install various GUI libraries and trying to make them work with Visual Studio, but none of these tries were successful.
It comes down to the problem of having to include the files and link the libraries. It seems, at least to me, extremely tedious and time consuming having to copy paste everything in those boxes in Visual Studio.
I need a helping hand to figure out what I'm doing wrong, here is how I tried:
Visual Studio 2017 - gtkmm library with the windows installer
I download the required Gtk+ and install it successfully.
I open the properties of my project, go to the includes and paste the required paths. I go to the linker and proceed to paste those paths.
Accept,try to paste a hello world program with the includes -> everything is underlined with red.
And this isn't even the actual gtkmm implementation.
Now my question is, did I forget a step or is it just the basic snippet that doesn't work (I'll spare you from posting it).
What do I do, when the tutorial for the library tells me to include 2 or 3 files whilst I have like 20 in my folder?
Also, is it somehow bad practice to place the libraries onto a different drive?
Sorry if I sound lost, but that's pretty much how I feel in those tutorials..
Edit, just in case, this is the snippet I'm referring to:
#include <gtk/gtk.h>
int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
g_printf("GTK+ version: %d.%d.%d\n", gtk_major_version,
gtk_minor_version, gtk_micro_version);
g_printf("Glib version: %d.%d.%d\n", glib_major_version,
glib_minor_version, glib_micro_version);
return 0;
}
g_printf, glib_major_version, glib_minor_version and glib_micro_version are red underlined, but not gtk_major_version
EDIT:
Thank you for the suggestions and the in-depth tutorial although questions like this don't fit stackoverflow.
Can you tell me how to include huge amounts of header and lib files when they are in many folders? Do you I need to access all folders manually and include them?
Yes, you undoubtedly missed a step in Visual Studio. No, its not bad to install it on another drive.
The general idea is:
1) Install the library somewhere on your machine. Doesn't really matter where. Take note of the "lib" directory and the "include" directory paths.
The include directory contains header files which allow your code to understand the forward declarations of the code your trying to use.
The lib directory contains the binaries (dll for dynamic linking, lib for static linking). Sometimes there are different binaries for release/debug. I'd link the debug library and worry about the release code when you get there
Note, sometimes they want you to compile the code yourself and create the binaries. They will include compile instructions. After you create the binaries you can go back to step 1 here and repeat the steps. This is because they either don't want to precompile binaries for your platform or their project philosophy is to do it yourself.
2) In Visual Studio you have to tell the compiler (separately) where the new additional include and library directories are. On 2017 that is...
Include Directory: Project > {Name} Properties > C/C++ > General > Additional Include Directories
Library Directory: Project > {Name} Properties > Linker > General > Additional Library Directories
3) Now include the libraries (binaries) themselves. On 2017 that is...
Library Binaries: Project > {Name} Properties > Linker > Input > Additional Dependencies
They should provide you a list of binaries to include in the project if there are external dependencies or they have broken their project up into multiple libraries for modularity.
If you want to program in C/C++, this is a process you're going to go through again and again. Its a bit arcane, but once you get it down, its not going to surprise you.
Edit:
Oh, and as an aside, people have mentioned Qt. This framework is a little different in regards to Visual Studio. Its very involved to set up the dependencies yourself because they have included language extensions and a tool for creating GUIs. For this reason, there is a tool (which is quite nice) for creating Qt projects from a template. This sets up all the compiler steps, includes, and linked libraries for you.
In my opinion its probably the best and most mature of the GUI libraries for C/C++ on Windows and is also cross platform.
I am trying to use the Console::SetCursorPosition(int, int) method. When I add the line using namespace System;, as shown in the C++ example from the preceding MSDN documentation, I get the error "Error: name must be a namespace name". I have been trying stuff for a couple hours now, but frustratingly without success. I have come across a ton of documentation for Visual Studio 2010 and 2012, but very little for 2013. The closest I have come is Lib Files as Linker Input. Steps 1-3 are easy enough, but step 4 is not clear to me: "Modify the Additional Dependencies property.". Looking at what is already there, it seems like I can just add a .lib file. But I don't have a System.lib.
So frustrated, so confused.
How can I use the System namespace in Visual Studio 2013 Update 4 for C++?
To formalize and expand on my comment, the Console class and generally the System namespace are part of the .NET framework.
In that context, the "C++" tab included in the MSDN documentation page of the Console::SetCursorPosition(int, int) method actually refers to the C++/CLI language. The C++/CLI language is distinct (although intentionally similar) from the C++ language. Correspondingly, the C++/CLI language contains various constructs which are not recognized by the C++ compiler toolset used when compiling Win32 projects.
In other words, to get rid of the "Error: name must be a namespace name" error, you would need to convert your Win32 C++ project to a CLR project. The easiest way to do that would be to create a new project, selecting one of the templates under "Visual C++" / "CLR":
The equivalent of .lib file depdendencies (relative to your Lib Files as Linker Input link) of Win32 projects for CLR project would be assembly references. You'd then typically add those assembly references with "Add References" under "Common Properties , References" project properties:
However, in your specific case you may very well find out that the System assembly reference is already included as part of the CLR project template.
You may want to check How to: Add or Remove References on MSDN for more details.
Finally, if you absolutely want to manually convert an existing Win32 project, you would need to set the "Common Language Runtime Support" project properties under "General" and the "C/C++ , General" tabs to one of /clr, /clr:pure, /clr:safe or /clr:oldSyntax (depending on your specific application requirements; if you're just toying around you might want to start with /clr) for all Configurations and Platforms as well as specify the targeted .Net framework version by directly editing the .vcxproj (as indicated in this answer). You would also still need to add assembly dependencies as with the new project approach above.
You have to set Common Language Runtime Support (/clr) in Configuration Properties - General:
And in Configuration Properties - C/C++ - General:
You are having a project of Win32 Console Application and and you are using .NET namespace. In Win32 Console Application only 4-5 namespace are there in standard library including std. Try using namespace std; at the top.
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.
I'm working on a project using C++, Boost, and Qt. I understand how to compress single files and bytestreams using, for example, the qCompress() function in Qt.
How do I zip a directory of multiple files, including subdirectories? I am looking for a cross-platform (Mac, Win, Linux) solution; I'd prefer not to fire off a bunch of new processes.
Is there a standard way to combine bytestreams from multiple files into a zipped archive, or maybe there is a convenience function or method that would be available in the Boost iostream library?
Many thanks for the assistance.
Update: The QuaZip library looks really great. There is an example in the download package (in the "tests" dir) that shows very clearly how to zip up a directory of files.
Update 2: After completing this task on my Linux build environment, I discovered that QuaZip doesn't work at all with the Visual Studio compiler. It may be possible to tackle all those compiler errors, but a word of caution to anyone looking down this path.
I have found the following two libraries:
ZipIOS++. Seems to be "pure" C++. They don't list Windows explicitly as a supported platform. So i think you should try your luck yourself.
QuaZIP. Based on Qt4. Actually looks nice. They list Windows explicitly (Using mingw). Apparently, it is a C++ wrapper for [this] library.
Ah, and of course, i have ripped those sites from this Qt Mailinglist question about Zipping/Unzipping of directories :)
Just for the record...
Today, I needed to do something very similar in Visual C++. (Though wanted to maintain the possibility to compile the project on other platforms; however preferred not to adopt Qt just for this purpose.)
Ended up using the Minizip library. It is written in plain C, but devising a simple C++ wrapper around it was a breeze, and the end result works great, at least for my purposes.
I have built a wrapper around minizip adding some features that I needed and making it nicer to use it. Is does use the latest c++11 and is developed using Visual Studio 2013, so it should work out-of-the-box for you.
There's a full description here: https://github.com/sebastiandev/zipper
you can zip entire folders, streams, vectors, etc. Also a nice feature is doing everything entirely in memory.
Poco::Zip is also a choice, it has clearly documentation and some code for demo.
Poco::Zip Document
system("zip myarchive.zip *");
I tried QuaZIP 0.4.3 on Windows with VisualStudio 2010 -- there are still issues but can be resolved easily.
To build with VS:
Use CMake to configure and generate VS solution for QuaZIP.
Open soltion with VS and build -- you'll first notice that it can't find 'zlib.h'.
Open preferences for quazip project and add path to Qt's copy of Zlib to C/C++->General->Additional Include Directories: $(QTDIR)/src/3rdparty/zlib.
Rebuild again and you'll get lots of warnings and one error C2491: dllimport static issue on QuaZipFile::staticMetaObject.
This is because QuaZipFile is declared like "class QUAZIP_EXPORT QuaZipFile" and QUAZIP_EXPORT needs to resolve to Q_DECL_EXPORT for dll and to Q_DECL_IMPORT for application, based on whether QUAZIP_BUILD is defined or not. When building QuaZIP QUAZIP_BUILD should be defined but isn't -- configuration process defines in error completely useless "quazip_EXPORTS" instead.
To fix, just remove "quazip_EXPORTS" from all build configurations and add QUAZIP_BUILD instead -- QuaZIP will now build fine.