Guest [n]ewcom3R Posted October 9, 2007 Posted October 9, 2007 (edited) Hi all,I have a big problem!! I wanted to create a C++ app. I have a resource file with dialog.. I defined my functions in a file named threads.cpp and the prototypes in a file named threads.hpp. The main dialog was defined in main.cppwhen i wanted to compile the project there were serveral errors:main.obj ERROR LNK2005main.obj ERROR LNK2019here are my files:threads.cpp#include "fstream"using namespace std;bool CreatePhPLoaderFile(char* PhpFileName){....}threads.hpp#include <windows.h>#include "Threads.cpp"#include "resource.h"HINSTANCE hInst;HWND dlgMain;bool CreatePhPLoaderFile(char* PhpFileName);and now my main.cpp<div class='codetop'>CODE<div class='codemain' style='height:200px;white-space:pre;overflow:auto'>#include "Threads.hpp"BOOL CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam).....</div></div> Edited October 9, 2007 by [n]ewcom3R
Killboy Posted October 9, 2007 Posted October 9, 2007 G-Sis how are we supposed to know what's wrong with it You stripped most of the source, I mean I can understand you don't want to show around your code but we're unable to help you without knowing anything. You should at least say what the exact error is (I guess you're using VC++ and it definately tells you what's wrong, at least most of the time) and where it happens (with the source code in that specific line !)... Otherwise, if this is the actual source, you need to start again, this time with HTML
Guest [n]ewcom3R Posted October 9, 2007 Posted October 9, 2007 Sorry !There is my build log. -------------- Build: default in PHP Loader ---------------Linking executable: PHP Loader.exemain.obj : error LNK2005: "bool __cdecl CreatePhPLoaderFile(char *)" (?CreatePhPLoaderFile@@YA_NPAD@Z) already defined in Threads.objmain.obj : error LNK2019: unresolved external symbol __imp__ShellExecuteA@24 referenced in function "int __stdcall DlgProc(struct HWND__ *,unsigned int,unsigned int,long)" (?DlgProc@@YGHPAUHWND__@@IIJ@Z)PHP Loader.exe : fatal error LNK1120: 1 unresolved externalsProcess terminated with status 1 (0 minutes, 0 seconds)My code is OK. There Error appears only if i adds the code witch is define in my threads.cpp. could it be that windows.h and fstream are incompatible? If I don't use fstream it works well!
Killboy Posted October 9, 2007 Posted October 9, 2007 Hum, the first error is obvious I guess, you defined it twice.The trick here is to define the function prototype of CreatePhPLoaderFile _before_ importing the .cpp that contains the actual code.I'm not really familiar with all the .h stuff, I just stumbled upon that behaviour and played around a little. I don't know if its only VC++ who's acting like that or if this is usual among all C[++] compilers (ie. defined as some sort of standard ?)...As for the second error, you seem to be missing a header for ShellExecuteA. I was able to compile an app using that API with those 2 includes:#include <windows.h>#include <stdlib.h>Otherwise you might have screwed your global setting, what with unicode and ascii. Maybe it's fstream.h ? no clue...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now