It may be an IDE specific problem but i encountered some weirdo voodoo situation with no ideas how to perform next.
I have two different projects (in two different folders) one for windows second for android. (i compile them on windows anyway)
For one i use Android Studio for second one i use RAD Studio, anyway they are two separated project sharing a library folder with source.
basically to share shared libraries i used:
mklink /D c:\anroid\project1/share e:\shared_lib
mklink /D e:\projects\c++\win\project2\share e:\shared_lib
Now shared libraries need to know either i want to compile WINDOWS or LINUX port so in each project root folder (which contains this share folder) i place three fies: PORTDEF.h, PATHDEF.h, PATH_DEF.cpp
where i put defines: (well actually ill show you the code maybe its important however header guards are used)
#ifndef PORT_DEFH
#define PORT_DEFH
//#define WINDOWS_PORT
#define LINUX_PORT
#endif
PATH_DEF.cpp
#ifndef pathdefcpp
#define pathdefcpp
#include "PATH_DEF.h"
CAnsiString APP_PATH;
CAnsiString DATA_PATH;
CAnsiString APP_PKG_NAME;
#endif
PATH_DEF.h
#ifndef PATH_DEFH
#define PATH_DEFH
#include "PORT_DEF.h"
#include "share/txtfile/stringlist.cpp"
#include "share/FileHandling.h"
extern CAnsiString APP_PATH;
extern CAnsiString DATA_PATH;
extern CAnsiString APP_PKG_NAME;
#ifdef WINDOWS_PORT
inline void FindPaths()
{
}
#endif
#ifdef LINUX_PORT
inline void FindPaths()
{
}
#endif
#endif
now in android project i have a main glcode.cpp file where i include
#include "PORT_DEF.h"
#include "PATH_DEF.cpp"
and files in share folder use them too in manner of that they are included with relative path
#include "../PORT_DEF.h"
#include "../PATH_DEF.cpp"
Hit build everything is fine and works…
However… on windows
There are 3 units. One is Project.cpp (which is the main compilation file) and Unit1.cpp, Unit2.cpp (along with their headers)
During writing this post i faced new issues so lets get over with it:
i hit compile and get multiple definition of 'DATA_PATH'
No having no idea what would cause that, i started poking around and ended with something like that:
in file share/sharedlib1.h cannot find file “.PORTDEF.h” @ #include “../PORT_DEF.h”
After an hour of trys and fails, i came with an idea to to add PORT_DEF.h to a project. (so it wil be visible for compiler)
but this requires me to change from #include “../PORTDEF.h” to #include “PORT_DEF.h”
i tried this in Androdi Studio (basically added this to cmakelists.txt)
include_directories(${CMAKE_SOURCE_DIR})
add_library(sharewithphone SHARED
PORT_DEF.h PATH_DEF.cpp gl_code.cpp)
hit compile
error: CMakeFiles/s/gl_code.cpp.o: multiple definition of 'DATA_PATH'
so i actually reproduced the same error on two IDEs now how i am supposed to to get rid of this multiple definition thingy.
I was searching for circular references there are none
basically these are all files included
#include <stdio.h>
#include <dirent.h>
#include <vector>
#include <fstream>
#include <sstream>
#include <math>
#include "string"
#include "stdlib.h"
#include <iostream>
#include <algorithm>
#include <cstring>
all cpp files have headerguards (ones that are included in #include) the same goes for all headers they too have headerguards
yet still even when including
PORT_DEF.h AND PATH_DEF.cpp at the beggining of project they shoul reside there
yet when hitting another file which uses these files it rants about mutiple declaration. ???? IM OUT OF IDEAS