Building C++ libraries/Sdk's

I am trying to create a program that takes a local file and upload to a cloud account.

So far I have 2 SDK's, from Mediafire and Mega

https://github.com/MediaFire/mediafire-cpp-sdk
https://github.com/meganz/sdk

I have been trying to use them (adding the header and source files directy to my project) but I can't get it to work because ii keep showing errors, if I "solve" one more come up.
The Mega SDK comes with a visual studio example project, I open it when I run it gives 680 errors.

In both Readme files they tell you the steps to build that library.
As a beginner I don't understand pretty much anything in those steps.

If anyone could help I would appreciate.

Thank You

Additional Info: I work on windows 10 64 bit machine, I use Codeblocks as my primary IDE, Visual Studio 17 my secondary
"As a beginner...."

Depending on how "beginner" you qualify yourself, you may well be in over your head.

The MediaFire library requires Boost. If you don't recognize that this means you need to install the Boost library, then you're in over your head.

Boost is quite famous to C++ programmers, in part because several libraries first developed and released as part of Boost subsequently became part of the standard C++ library. For example, std::shared_ptr came through Boost.

So, MediaFire isn't going to compile unless you have Boost, which is...another library.

Let me point out that you are thinking in the right direction. Consuming libraries for development is a smart way to develop software. Too many students develop considerable skills, then move on to shun the use of libraries, even though it would save them considerable time.

So, would you consider yourself familiar with how to write C++ console mode applications? Are you familiar with the C++ standard library? Are you comfortable with std::shared_ptr, the containers like std::vector, std::map and others?

Are you familiar with command line build tools? CMake? Ninja?

The task before you depends on how far you already are. If by beginner you mean familiar with functions, loops, declarations, but nothing else, then you'll need to become more familiar with the basic notion of building a project.

If, however, you're familiar with having generated a project with at least 2 or more translation units (CPP files), then your next task is to familiarize yourself with the various methods of building and configuring.

Most libraries are made to be portable among operating systems. As such, they use generic build tools intended for that purpose, with CMake being among the more common.

So, for each and every term you found unfamiliar in the instructions for MediaFire or meganz, you'll need to research those terms, those tools, and read through documentation or tutorial information on them.

Even professionals must do this all the time. I've been at this 40+ years, and this has been a constant. For example, to build Android applications, one writes Java code and builds with Gradle. If the project includes native code (C++), there are files to edit in order to configure a complex build. However, that is more recent. Before 2017 (maybe it was 2015, I don't exactly remember), the build tool was "ant". I had to research, learn and adjust every time they changed whatever details were involved.

Of course, with considerable experience behind me, all of these tools are merely a change of details on the same basic concept, and you may well be at the stage of still learning the basic concept of a build system.

The "original", with respect to C, was "make". I used make in the 80's. I'm glad I don't use it much now, but even lately it has come back up now and then. I still have to look up the details occasionally. I use it for a few weeks, then put it aside, move on, and it might be 2 years before I see it again. By then, it's no longer fresh in mind, so I have to review the specifics.

This is a constant of the industry and the profession.

Since Boost is a prerequisite to MediaFire, and Boost is rather straightforward to build (though the details are a winding road), I suggest you get and build Boost.

That may be most of what is required to get the Visual Studio based example project working, because if you don't have Boost, that is likely part of what it complains about.

Along the way you're going to have to figure out how you "connect" that project to the installation of Boost on your machine. The basic notion is that you must inform any compiler or "make" system what directories should be searched for includes. In the case of Boost, they use an automatic configuration approach which informs the linker for you where to find the binary libraries, but not all libraries do that, so sometimes you have both include files (for the compilation stage) and library directories (for the link stage) to configure.

This is intermediate material, bordering on entry into the advanced material with respect to project configuration (build configuration). You have to get through it eventually, and you have to get used to research eventually - this is your moment.

Along the way you'll begin to recognize that the first 10 or so errors are usually all that really matters (with the exception of errors in complex template code, that can be the first 40 or so). After that, most are "cascades" of errors. These are errors happening because of the first 10 errors in the list. Sometimes you fix one thing and 100 errors disappear. That might reveal another problem which adds 200 errors, so you may think you're stepping backwards when you're not. Compilers and linkers are not particularly good and pertinent, descriptive errors which state what you should fix. Instead, the complain about certain details, where you must learn the diagnostic skill of figuring out what is meant, not what is said.

Sometimes it is a good, correct, concise and clear error message. Sometimes, in template code, there are 20 errors listing header file after header file, then pointing to some code you wrote, all based on one small typo.

It will not matter to any of us out here how many errors appear. One missing library file could generate 500 errors or 20 errors, but that still represents only 1 thing to be fixed.

What matters are what the first 10 or 20 say.

We can't read those unless you post them.
Last edited on
windows, most major libraries have a compiled already version you can just use without going through all this pain. Not all, but most. If you are very, very new to this and want to defer until you understand it better, see if you can just get a DLL file or LIB file ready to go for the tools and skip this step for now.

Unix type OS usually do not have this because there are hundreds of versions and hundreds of CPUs that it supports so they don't feel that building all those versions is practical (rightly so).

Case in point, BOOST should have a precompiled version you can just use.

if you want to learn this process, carry on. You will have to learn it someday, but its not friendly to novices.
Last edited on
Hi Niccolo, thanks for your answer

Depending on how "beginner" you qualify yourself, you may well be in over your head.

I would say a beginner at the intermediate gate.

this repository on my github would give you a clear idea (I think) on where I am on C++ even though I have grown a little since I made that
https://github.com/hbtalha/ATM-Online-Bank-Account

The MediaFire library requires Boost. If you don't recognize that this means you need to install the Boost library, then you're in over your head.

Yes, I am using boost, I just started it out

Are you familiar with the C++ standard library?
Yes I am familiar

Are you comfortable with std::shared_ptr,

I have studied the concepts of std::shared_pt but I am not familiar with it (actually I normally don't use any kind of pointer) because I haven't yet seen the purpose of using one in my programs, I know pointer is an important feature and one should learn how to use it efficiently but after many searches I still haven't seen its advantage on any pratical work I have done so far.

the containers like std::vector, std::map and others?
yes, very confortable, I have created programs that rely heavily on them

Are you familiar with command line build tools? CMake? Ninja?

That is my next step I think, I don't know about command line build tools, CMake I have seen it everywhere and still don't know what it is really for, never heard of Ninja.

Thank you for the insight, it was very helpful

The mediafire I have only tried to use it on codeblocks where I use the boost library.
With mega I have opened the example provided for visual studio again and it gave some errors (I am not being able to reproduce those 680 errors again), now it is giving errors aboyt missing files, even I have downloaded those files and copy to that folder.

About those 680 errors here are some of the errors I tried looking up
include\chrono(786): error C2440: '': cannot convert from '__int64' to 'std::chrono::system_clock::duration'

1
2
3
4
5
include\ratio(73): error C2065: 'INTMAX_MAX': undeclared identifier

include\chrono(767): error C2938: 'std::ratio_multiply<std::ratio<100,1>,std::nano>' : Failed to specialize alias template

\include\chrono(767): error C2938: 'std::ratio_multiply<std::ratio<100,1>,std::nano>' : Failed to specialize alias template


I will reading their Readme files again and this time following your advice
About those 680 errors here are some of the errors I tried looking up

Don't forget that you need to work on errors/warnings from the top down. Fixing one problem can often fix several of the following problems.

The errors you posted are a good indication of the above problem, rarely will there be errors in the standard include files. The problem is earlier, usually somewhere in your code.

yes I read them from top down

the problem is that errors are in the files of the api, that I don't know how they work
it does not matter how they work. What matters is the topmost error and what it is telling you about your attempt to compile it -- you are not looking for busted code to fix, you are looking for something that tells you what you did wrong compiling code that you know works. Usually this is going to boil down to 'something not found' ... that usually being some other library that this one needs, or some header it needs but isnt in the path, or the like.

what is the top most error #1 error? Post it.

if it is an undefined type, you have to figure out where that is and why its not seeing it. If its a missing include file ... etc.
I know you are on windows but this is a good case for having grep on all systems, or something like it. You can use that to figure out where the missing thing is defined by grepping all the .h files in the folder tree, or pulling out all the nonstandard #includes in all the headers into one pile, deduplicate it, and see what you don't have. Unfortunately many libs use <> instead of "" header include notation, making this more work than it needed to be. You also have to often tell the build utility things, like what OS you are on, so you don't have windows trying to catch a unistd or unix trying to make calls into windows.h etc.

if you don't have grep, you can get it from cygwin and you can just dump its executable files path into your normal path and use the tools from the windows shell, you don't HAVE to use their unix vm shell thingy. A few things need their shell but grep, ls, and things like that do not. as a perk, you can pick up their g++ compiler while you are at it, in case you want a second opinion.
Last edited on
In megasync you can just copy the file directly into the sync folder and it will be uploaded.
include\ratio(73): error C2065: 'INTMAX_MAX': undeclared identifier

include\chrono(767): error C2938: 'std::ratio_multiply<std::ratio<100,1>,std::nano>' : Failed to specialize alias template

\include\chrono(767): error C2938: 'std::ratio_multiply<std::ratio<100,1>,std::nano>' : Failed to specialize alias template


The two errors reported from "include\chrono" suggest these are complaints in the standard library code, which naturally propagate from some usage of the standard library (this is a cascading error). It is likely the error list echoes through several like this complaining about code in the standard library, which generally can't be a genuine complaint (otherwise the compiler couldn't use the libraries at all). Instead, skip forward until a complaint references one of the files from the application software, not the standard library, for that code which generated this cascading series.

That said, "INTMAX_MAX", in all caps, suggests a macro that is not defined. This hints to the kind of "definition by macro" which requires a kind of configuration of source which has not been performed.

I have to guess here, but "INTMAX_MAX" hints that this gives the maximum value of the largest integer on your platform. Sometimes these are defined based on conditional includes (other defines) which state the platform. Something like

1
2
3
4
5
#ifdef BIT_64
#include "platform64_defs.h"
#else
#include "platform32_defs.h"
#endif 


...though that is just a contrived example. The point I'm making is that this hints at a configuration step used to define how to declare INTMAX_MAX (and likely a bunch of other such platform dependent mutations).

I don't see that one often, but INTMAX_MAX may be somewhat conventional, and might require the define __STDC_LIMIT_MACROS in some compilers, or a choice of including <cstdint> as opposed to including <stdint.h> (or the reverse).

That's the kind of configuration I'm talking about.



Last edited on
Sorry for the late reply, I got a virus that wiped out my entire C drive.

I followed the advices given in the last two replies but I haven't got anywhere near my goal.

So I have come to the conclusion that I need to build a stronger foundation around c++ and go back to that later.

As a beginner (close to intermediate) I found myself not understanding many things that were said in the Readme files so I take that as a sign that I need to obtain more knowledge and practice.

I have been learning cpp only in book and it was of a great help for me to get the grasp of everything I know in cpp. But I wonder if there is another method that you guys use to learn any programming language that may really put your skills to test or bring some benefits that book don't.

Others may have a book.
coursework and decades of experience give you a foundation in general design principles that you use no matter what language. Then you just figure out how to express the idea and design you have in the language at hand.

But this is not your problem for the library issue.
The library issue is that C and by inheritance, compilation of C++ projects at the command line level are an unholy mess that is difficult to learn and use. Once you get it, and do it for a while, and so on you get a feel for why it is done that way and how to make it work, but I have no answer on this beyond brutal hands on experience and beating your head on the web trying to make sense of what you are being told (which is tough because the info assumes you know the background that you are trying to get but don't yet have, its a nasty circle). There are some how-to sites, but they still take some time to absorb it all. There is a commandline OS level to it all too -- understanding environment variables, relative paths, and so on is necessary. This is a skill you want to have anyway, learn how to use the commandline and it will serve you well as a coder. As long as I have coded, and with a pretty rich background in the field, I still cringe at trying to build a big library. I can get it working, but I don't do it that often, and so each time I just go into it expecting it to be a hassle.

Last edited on
I echo @jonnin's points. I don't think I've read any book with this particular material. This is the stuff only experience, experiment and research get you through.

"As long as I have coded, and with a pretty rich background in the field, I still cringe at trying to build a big library."


I could have written this sentence myself.

Just recently I assisted an engineer with a library I've never heard of (it is in computational chemistry). It was dependent on Boost. The original library was intended for Linux. The engineer uses MAC. Instructions were of some help, but I had to "substitute" the procedure one uses for Linux to a counterpart on the MAC.

This is the kind of thing that comes up all the time. It is also something we do far less often than writing software. An IDE makes this simple. You start a project from some template (say a console application), add a few source files, then hit build.

This is where you're just going to have to get used to searching for the various terms you find unfamiliar, and dig.

You may well be right to put it off for a while, but there will be a point where a trial by fire is the only way from where you are to where you want/need to be with this kind of thing.

Boost may well be a good starting point, because it does build on most platforms, so you generally end up getting that to work. They have their own build system, but at least they do have instructions and documentation. The default build is probably not quite what you want in the long run, so you have to figure out some of the optional commands you can supply. For example, you may want to build the libraries for debug and release, both threaded and multi-threaded, for runtime static and runtime dynamic libraries. For boost, my own opinion is the best way to do this is by the "stage" option, but one must choose how that is named using the "layout" option.

If you have no idea what "stage" and "layout" mean, as I expect, you are in good company. Most don't, unless they've built boost, because it only applies to boost. If you can manage to research those two terms and figure out how to use them as options on the command line to get boost built with them, you've probably taken yourself over that bar in front of you, and others will start to make more sense.



In my admittedly very limited experience one of the easiest libraries to build is Boost. The creators have virtually automated the build process for most major operating systems and compilers.

And if someone wants to dig into the build process there is documentation available.
@hbcpp,

I glanced at the dependencies for the MEGA SDK, and my blood ran cold. Yow, definitely not a library for a beginner.

IMO.

You opened the VS example and got 680+ errors when trying to compile it because I doubt you have any of the other library requirements available. Crypto++ or zlib at a minimum if you use native Win32 WinHTTP.
Last edited on
@Furry Guy, I did download the Crypto++ (not zlib though) but I just couldn't use it (at least the right way).
I say this is primarily because my IDE of choice for c++ is codeblocks and I have little experince with VS, I found codeblocks more suitable for a beginner than VS so I stuck with it until now and I do find, after all this time, codeblocks still better for me. It is more straight to the point if this is the right description even though VS is a lot richer.

And as with The MEGA SDK, I could tell that the library was not for a beginner that's why I came here looking if someone could give a step by step guide to use it and from there I would've learned a lot of things new.
But after a lot of search and the replies that @Niccolo gave me I saw that it will be better if I strengthen foundation a little more and that is what I have been trying to do.

And this like @jonnin said, I will have have to go after my experiences and beat my head everywhere I can if that means I am learning and improving my skills

I thank you guys for the time you spent here giving your insights and helping.
I never built a library, so I guess this is the first thing I ought to do.
I use boost but I've downloaded it together with this very good MinGW distribution here https://nuwen.net/mingw.html

Any library suggested for me to try to build??
Build Boost yourself.

The process is scripted for the most part, but you can configure how the process is done.

When a new version of Boost is released I download it and build a version that works with Visual Studio 2017 and another version that works with VS 2019.

I also create each version to be usable for 32 bit apps and 64 bit apps.

I build so each version is usable as a static library, no DLLs created. Header and lib files only.

I could build Boost DLLs if I wanted. I would change the parameters of how I do the build.

Read the Boost installation instructions, they are not that hard to understand for a first time library user.
Read the instructions, and try building different configurations using different build parameters. Create one build, see what that configuration did. Delete the created directories and start a new, differently configured build. That is how I figured out how to get what I wanted with a build.

Building and using a 3rd party library can be a HUGE hurdle to overcome the first time. Each new library you muck around with the build process gets easier.

After you have built Boost yourself, and can successfully create some Boost examples, ask for suggestions of other libraries that at most have Boost as a dependency.
Last edited on
@Furry Guy, thanks for the tips, I will make sure to build the Boost Library myself.

Once again, thanks for the help!!
After you've build Boost and have it working the way you want you could start learning how to use make files.

Knowing how to build apps you create using the commandline helps becoming a more savvy programmer.

Not every library can be built by Windows without a lot of work, many are meant for Mac/*nix.
You might have to modify a build script/make file to work with Windows.
I really thank you @Furry Guy, I am really needing some guidance.

I have read three beginner's books and now I am trying some more advanced ones.
And now I am starting to wonder what next cause I have learned from the basics to the STL's and a little of templates and I got really carried away solving problems(I love problems) I found on the book's exercises but I am not sure how will they help me being a c++ programmer (that's because I often find myself wondering what professional c++ programmers code daily in their jobs, the real-world apps they talk so much in the books).

I may be wanting to go too fast and I don't know if this is normal.

If you could share some of your personal experience it would help me a lot.

And yes I have moved away from the topic of the post and please let me know if this is wrong and what do I have to do about it as this is the second time I am posting in this forum.

Thank you
Topic archived. No new replies allowed.