0

main.cpp

#include "includes.h"
#include "LOGMSGs.h"

int main()
{
LOGMSG("TEST");



	getch();
	return 0;
}

MYSQLcon.cpp

#include "LOGMSGs.h"
int Mysql()
{
	MYSQL *con, mysql;
	mysql_init(&mysql);
	const char * host="localhost";
	const char * user="test";
	const char * pass="test";
	const char * db="NewServer";
	con = mysql_real_connect(&mysql,host,user,pass,db,NULL,NULL,NULL);
	if (con == NULL) {
	Error(mysql_error(&mysql));
	return 1;
	}
	LOGMSG("MySQL Connected successfully");

}

Error: error LNK2005: "void __cdecl LOGMSG(char const *,...)" (?LOGMSG@@YAXPBDZZ) already defined in main.obj

what's wrong

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Mr_PoP
0

If you look in logmsgs.h you will probably find that function defined there. You can not put executable code in header files because it results in the error message that you got. Put just the function prototype in the header file and the actual function in one of the *.cpp files.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.