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

Recommended Answers

All 2 Replies

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.

thnx worked :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.