Multiple forms problem C++ / CLI
-
Hi everyone ! Please help me , because i have a big trouble !!! I have login form , and i want to open form1 Form from login form. I tryed use #include "Form1.h" in "login.h" login form where is. Unfortunately i had problems and many mistakes such like : Error 198 error LNK2005: "int SymulacjaObiektuSISO::i1" (?i1@SymulacjaObiektuSISO@@3HA) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO Error 199 error LNK2005: "int SymulacjaObiektuSISO::i2" (?i2@SymulacjaObiektuSISO@@3HA) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO Error 214 error LNK2005: "class std::deque<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > SymulacjaObiektuSISO::nazwyGeneratorow" (?nazwyGeneratorow@SymulacjaObiektuSISO@@3V?$deque@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@A) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO and i think this is because of #include files which are in form1.h unfortunately i can't open form1 from login form : Form1^ test = gcnew Form1^(); i don't know what to do... please help me because i must do this !!!! How can i resolve this problem ?? Login form -> open form1 form , and form1.h has the others #include files just like "test1.h" and ect. Plese help me as fast as You can
-
Hi everyone ! Please help me , because i have a big trouble !!! I have login form , and i want to open form1 Form from login form. I tryed use #include "Form1.h" in "login.h" login form where is. Unfortunately i had problems and many mistakes such like : Error 198 error LNK2005: "int SymulacjaObiektuSISO::i1" (?i1@SymulacjaObiektuSISO@@3HA) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO Error 199 error LNK2005: "int SymulacjaObiektuSISO::i2" (?i2@SymulacjaObiektuSISO@@3HA) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO Error 214 error LNK2005: "class std::deque<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > SymulacjaObiektuSISO::nazwyGeneratorow" (?nazwyGeneratorow@SymulacjaObiektuSISO@@3V?$deque@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@A) already defined in Logowanie.obj Symulacja Obiektu SISO.obj Symulacja Obiektu SISO and i think this is because of #include files which are in form1.h unfortunately i can't open form1 from login form : Form1^ test = gcnew Form1^(); i don't know what to do... please help me because i must do this !!!! How can i resolve this problem ?? Login form -> open form1 form , and form1.h has the others #include files just like "test1.h" and ect. Plese help me as fast as You can
the problem come from this -> "Login form -> open form1 form , and form1.h has the others #include files just like "test1.h" and ect." the include file must be correct utilized cause they can lead to your problem. in an ideal world you should include the .h files like in a tree:
super\_main.h / \\ main1.h main2.h / \\
submain1_1.h submain1_2.h
where each .h have one .cpp with the operational code -- or -- there are some workaround like #ifndef #define ....code.... #endif to make life easier when implementing .h :)
-
the problem come from this -> "Login form -> open form1 form , and form1.h has the others #include files just like "test1.h" and ect." the include file must be correct utilized cause they can lead to your problem. in an ideal world you should include the .h files like in a tree:
super\_main.h / \\ main1.h main2.h / \\
submain1_1.h submain1_2.h
where each .h have one .cpp with the operational code -- or -- there are some workaround like #ifndef #define ....code.... #endif to make life easier when implementing .h :)
Thanks for the reply ! Yes of course I usually write #ifndef ect. definition into header files, but it's not a problem with this... main issue of this is in the namespace... because my major project is in C++ CLI how's You know isn't the same what is pure C++ ( unmanaged probably ) so, i'm not able to declare object of pure class ( example : class Test; and in managed class : ref class { ... public : Test object; ) i understand how can i resolve this problem -> i should declare pointer of unmanaged class : Test *object into managed class. But unfortunately my supervisor ( he hasn't seen my project yet ) wants or requires use auto_ptr ( because of memory leak ) , so i use this "intelligent" pointer in namespace area : namespace TestSpace { auto_ptr object; ref class ClassTest { object->... }; } and it works, but main problem is when i compile this code , and i have main order with header files same to You , 'm receiving information about the same or two definitions ( already defined ). I noticed that i haven't this problem if i don't use or i don't declare all of objects , variables in namespace like above... i think it's because of declarations in namespace , Ideal solution would be place declarations into ref class and i think it won't be compile error , but how's i said unfortunately we can't declare auto_ptr in ref class because of unmanaged and managed code error , and this is infinite loop... if i hadn't seen on my supervisior i would have written this with usual pointers ... : Test *object in ref class and no problem for me... but i can't imagine what would be if my teacher see this solution... Of course if you don't find any more precisely solution , i'll do this with convenient linker option : /FORCE and i don't see this error... but You know... it's just like an strong solution... Thanks for help