Hello,
I have some problem with unresolved external and cannot find out how this happens.
I am on Windows Visual Studio where I have file stdafx.h which includes headers. Standard files like string, vector etc. are there. The program worked until I decided to create one more file to include functions and definitions. Last 5 lines from stdafx.h:
1 2 3 4 5
|
#include "definitions.h" // constants
#include "fnc.h" // my functions
#include "myColorConverter.h"
#include "strings.h"
#include "file.h" // GetEncoderClsid; MyGlobalClass::IsDirectory
|
Main project file is called parse3.cpp and it starts like this:
1 2 3
|
#include "stdafx.h"
#include "main.h" // MyGlobalClass
using namespace std;
|
Header of fnc.h (the file I just added):
1 2
|
void error(char * str);
LIMITS1 getNumberFromRegex(std::string s, char ch);
|
Header of definitions.h (another file I just added):
1 2 3 4 5 6 7 8 9 10
|
#ifndef DESTINATION_CONST
#define DESTINATION_CONST
#define ERR_regex ": bracket not found in regex: {y:number} or {x:number}"
#define ERR_regex_ "Incorrect syntax in -r regex. Expression expected: {x:number}_{y:number} or {y:number}_{x:number} or similar."
struct LIMITS1 { int min; int max; } Limits1;
struct LIMITS2 { int xmin; int xmax; int ymin; int ymax; } Limits2;
#endif
|
And the fnc.cpp:
http://paste.ofcode.org/vRE2JvhprULRg5rtUGPkge
there is no definitions.cpp
I got these errors:
------ Debug Win32 ------
parse3.cpp
Generating Code...
Compiling...
stdafx.cpp
fnc.cpp
fnc.cpp(17): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\c++\visual studio 10.0\vc\include\string.h(188) : see declaration of 'strncpy'
fnc.cpp(22): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\c++\visual studio 10.0\vc\include\string.h(188) : see declaration of 'strncpy'
fnc.cpp(23): warning C4996: 'strtok': This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\c++\visual studio 10.0\vc\include\string.h(197) : see declaration of 'strtok'
fnc.cpp(25): warning C4996: 'strtok': This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\c++\visual studio 10.0\vc\include\string.h(197) : see declaration of 'strtok'
file.cpp
Generating Code...
fnc.obj : error LNK2005: "
struct LIMITS1 Limits1" (?Limits1@@3ULIMITS1@@A) already defined in file.obj
fnc.obj : error LNK2005: "
struct LIMITS2 Limits2" (?Limits2@@3ULIMITS2@@A) already defined in file.obj
parse3.obj : error LNK2005: "
struct LIMITS1 Limits1" (?Limits1@@3ULIMITS1@@A) already defined in file.obj
parse3.obj : error LNK2005: "
struct LIMITS2 Limits2" (?Limits2@@3ULIMITS2@@A) already defined in file.obj
stdafx.obj : error LNK2005: "
struct LIMITS1 Limits1" (?Limits1@@3ULIMITS1@@A) already defined in file.obj
stdafx.obj : error LNK2005: "
struct LIMITS2 Limits2" (?Limits2@@3ULIMITS2@@A) already defined in file.obj
fnc.obj : error LNK2019:
unresolved external symbol "void __cdecl error(char *)" (?error@@YAXPAD@Z)
referenced in function "struct LIMITS1 __cdecl getNumberFromRegex(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,char)" (?getNumberFromRegex@@YA?AULIMITS1@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@D@Z)
Debug\parse3.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Can you find what's wrong?