API's and my struggle to understand them.

okay, so the title is a tiny bit misleading. my misunderstanding is not with what API's are, it's more or less how to use them. See I'm trying to learn how to use the MySQL API for C and C++ and I have watched several tutorials on how to actually use the functions it provides to you. so I understand the API's functionality, I just don't know how to get it installed. I blame this partly on my own lack of experience,but I'm mostly blame it onmy lack of knowledge about the terminology.I've never been through an actual programming course, and almost every single youtube series that teaches programming language has its flaws.so whenever I look up some sort of tutorial on how to install an API I end up with a headachebecause most everything the talking about in tutorials like that is unfamiliar to me.one of the biggest problems I've been running into so far, after I link the library's to my compiler it always says that I am missing some files. Normally header files.and it usually leaves me at a complete loss, because when I go online to find the files that I am missing and then install them, it says that I'm missing more files afterwards. So it sends me on this big wild goose chase that I can never seem to end.

next year, I will be in college for computer science. I feel if I do not understand how to install an API by that point I will be in deep trouble.

I'd appreciate whatever help and suggestions anyone can offer me. This community has been a great help to me in the past, and I'm hoping you can help me with this.

(oh and by the way, the compiler I use his code ::blocks, but I am soon going to upgrade to Microsoft Visual StudioProfessional 2010.)
don't worry, intro comp sci courses aren't very hard and won't cover API most likely.
Regardless, its still something i need to learn about.
closed account (2AoiNwbp)
I don't know what you already know about API functions and data structures, but I can tell you that they come in .dll files (for Windows) and if you want to use them, you need both, the header files (.h or .hpp) and the library files (.lib) which will link your code with the APIs in the .dll's
If you miss any of them, your compiler/linker will fail.
You only need to know how to use the funcionality provided in c or c++ code, and never forget to tell the linker about the .libs.
Hope this help a little bit

Alejandro
Do you need to tell the linker about ALL the .lib files? Because some API's i was working with had hundreds. And what about the .h & .hpp files? Do i copy them into my existing compilers library or will linking the libraries do that for me? or if i recall (because i don't have access to code blockjs at this very moment in time) i declare where all the .h & .hpp files are on there own? And the .dll files, what do i do with those? Please elaborate more if you may.
closed account (2AoiNwbp)
I've never used MySQL specifically, but normally, if you want to code using a third party API, you would get a package containing the sources and then you would build them using a tool such as make, or cmake, or nmake or whatever. Of course, you'll need a compiler for this. This way, you would produce the .lib's and .dll's you need. I would read the installation instructions to do so. If your vendor doesn't provide good documentation for this, you can always search the internet, and perhaps someone else did it.

I don't know how you specify the directories in code::blocks, but it shouldn't be difficult. I use VS 2010 and I set up the directories in the project properties.
You wouldn't copy the .h and the .lib's into your compilers library, because it is not clean, and it would be very difficult to upgrade to a newer version. Instead, you can have a folder "C:\MyAPIv1.0" and another "C:\MyAPIv2.0" just pointing your compiler/linker to the correct version.

You can also try using static linking your .lib's, so you don't need to use the .dll's, although your program will be bigger.

Hope this might help.

regards,
Alejandro
it does help, thank you very much. Know of any place i may be able to go to find an in depth tutorial on some API stuff? What your saying is helpful but a place i could go to really read into it would be great.
Oh, geez. the USP guy literally just arrived with the activation code to VS Pro 2010... Haha (the reason why it was mailed to me is a long hellish story so i won't get into it :P But now i can use it to download the program) should hopefully make things easier.
Last edited on
closed account (2AoiNwbp)
Unfortunatelly I can't tell you what documentation is good for this... I would tell you: pick some API of your interest, find the packages, find the installation notes, and try it!
But let me check if I can find something out there...
closed account (2AoiNwbp)
I think that these might well worth a look:

http://dev.mysql.com/doc/refman/5.0/en/c-api.html
http://dev.mysql.com/doc/connector-cpp/en/index.html

enjoy!

regards,
Alejandro
Thank you very much sir! :)
closed account (2AoiNwbp)
The same I told you, but much simpler (it's in the links above)

Compiling MySQL Clients on Microsoft Windows

To specify header and library file locations, use the facilities provided by your development environment.

On Windows, you can link your code with either the dynamic or static C client library. The static library is named mysqlclient.lib and the dynamic library is named libmysql.dll. In addition, the libmysql.lib static import library is needed for using the dynamic library.

If you link with the static library, failure can occur unless these conditions are satisfied:

The client application must be compiled with the same version of Visual Studio used to compile the library.

The client application should link the C runtime statically by using the /MT compiler option.

If the client application is built in in debug mode and uses the static debug C runtime (/MTd compiler option), it can link to the mysqlclient.lib static library if that library was built using the same option. If the client application uses the dynamic C runtime (/MD option, or /MDd option in debug mode), it must must be linked to the libmysql.dll dynamic library. It cannot link to the static client library.


now, you can do it

regards,
Alejandro
closed account (2AoiNwbp)
you are very welcome

regards,
Alejandro
If i may, i'd like to start this thread up again because i have run into a new problem with this regarding problems linking the library.
I can't seem to get the dynamic library (.dll) to work properly.
closed account (2AoiNwbp)
why? can you give further details?
"fatal error LNK1107: invalid or corrupt file: cannot read at 0x368"

That's the error message I seem to be gettibg. Everything I have checked on it says it's a problem with using a .dll file
closed account (2AoiNwbp)
Are you using Visual Studio? You might need to add additional dependencies (.lib or .dll files) at project properties
check here:
http://social.msdn.microsoft.com/Forums/en-US/81c26278-3965-4567-8b1a-bb9e98b5f53a/fatal-error-lnk1107-invalid-or-corrupt-file-cannot-read-at-0x168?forum=vcgeneral
Topic archived. No new replies allowed.