469,106 Members | 2,262 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,106 developers. It's quick & easy.

Using MySQL C API in Visual C++ .Net

Dear group

I am a newbie to C++, so probably this question has a very obvious answer:
I try to compile the example from the MySQL docu on
http://dev.mysql.com/doc/mysql/en/li...d_example.html

I added the library and include directories; added libmysql.lib as source
file in the solution explroer, added #include <winsock.h> at the beginning
of the file. Yet, I still get the error message
mySQL error LNK2019: unresolved external symbol _mysql_server_init@
12 referenced in function _main

Any hints?

Best regards, Wolfgang
Jul 20 '05 #1
4 2967
Baui <bauerwo wrote:
I am a newbie to C++, so probably this question has a very obvious answer:
In the subject line you talk about C, and here you talk about C++. They
are two different languages. Which one do you want to use?
I try to compile the example from the MySQL docu on
http://dev.mysql.com/doc/mysql/en/li...d_example.html


That example is in C.

There is also C++ API available if you are interested in it. Don't know
if it is any easier to install, but might be easier to use if you want
to use C++.

You can find "MySQL++ 1.7.1 for Microsoft Visual C++ 6.0" from:

http://dev.mysql.com/downloads/other/plusplus/

I know nothing about .net so I don't know if that works on it. But I
could bulieve it does. There is also a project file in the example.

But you need to set your include and library paths to your compiler. In
VC 6.0 that would be found in tools -> options -> directories. You will
need to have include folder in the zip file in that path. But you will
also need to have the include folder which came with the MySQL in the
path. ( You would need to have the same include folder in your compiler
settings with the C API also, and since you didn't mention adding it,
this might be the reason why getting the error, if you want to try the C
api instead of C++. )
Jul 20 '05 #2
Many thanks, I'll try the mysql++.

Just a dumb question: what do I need to do to compile a C program in Visual
C++? I thought it was enough not to use any c++ libraries or commands, but
apparently this is wrong...

Thanks, Wolfgang
Jul 20 '05 #3
bauerwo gmx.net wrote:
Just a dumb question: what do I need to do to compile a C program in Visual
C++? I thought it was enough not to use any c++ libraries or commands, but
apparently this is wrong...


I don't know. I have no experience in compiling C with Visual C++. Some
C programs compile directly with C++ compiler, because of similarities
these two programming languages have. But that doesn't apply to all
situations.

But microsoft.public.vc.* hierarchy should have some newsgroup(s) where
someone knows answer to that one.
Jul 20 '05 #4
In article <Fj**************@read3.inet.fi>, sp**********@yahoo.com
says...
bauerwo gmx.net wrote:
Just a dumb question: what do I need to do to compile a C program in Visual
C++? I thought it was enough not to use any c++ libraries or commands, but
apparently this is wrong...


I don't know. I have no experience in compiling C with Visual C++. Some
C programs compile directly with C++ compiler, because of similarities
these two programming languages have. But that doesn't apply to all
situations.

But microsoft.public.vc.* hierarchy should have some newsgroup(s) where
someone knows answer to that one.

With VC 6
If the source files are named "foo.c" then they are compiles as C

If the source files are named "foo.cpp" then the C++ compiler is used.
As long as the source files contain no C++ specific syntax, only the C
libaries are used during linking.

The advantage of compiling C sources with the ++ compiler is that much
better type checking is done, this forces you to write better code.

It is a good idea not to mix C and C++ source files in a project, just
rename "foo.c" to "foo.cpp"

C++ contains all of C as a subset.

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Tawfik Rady | last post: by
2 posts views Thread by simen.haugen | last post: by
3 posts views Thread by filip.norrgard | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.