www.digitalmars.com         C & C++   DMDScript  

c++.command-line - compilation problem

reply Fibre Optic <fibre_optic go2.pl> writes:
Hello,

i am trying to pleay with example from such a book: Professional C++ 
(Programmer to Programmer). After compilation I have such output:

sc Database.cpp -cpp -Ae -r -mn -o+time -WA -s -3 -a8 -c -gp 
-D_CONSOLE=1 -IC:\DM-cpp\stlport\stlport -oDatabase.obj
Warning: C:\Dev-Cpp\Projects\C++\EmployeeDB\Database.cpp(48): implied 
return of Records::Database::getEmployee at closing '}' does not return 
value
Warning: C:\Dev-Cpp\Projects\C++\EmployeeDB\Database.cpp(60): implied 
return of Records::Database::getEmployee at closing '}' does not return 
value
sc Employee.cpp -cpp -Ae -r -mn -o+time -WA -s -3 -a8 -c -gp 
-D_CONSOLE=1 -IC:\DM-cpp\stlport\stlport -oEmployee.obj
sc UserInterface.cpp -cpp -Ae -r -mn -o+time -WA -s -3 -a8 -c -gp 
-D_CONSOLE=1 -IC:\DM-cpp\stlport\stlport -oUserInterface.obj
link /NOI /DE /PACKF /XN /NT /ENTRY:mainCRTStartup /BAS:4194304 /A:512 
 EmployeeDB.LNK
ren .\$SCW$.EXE EmployeeDB.EXE
.\EmployeeDB.EXE built
Lines Processed: 52508  Errors: 0  Warnings: 2
Successful build


So, it looks ok. but after start up on screen I see menu in console 
window (this is ok.) but when I chose option i.e. 0-6 I see new M$ 
Windows like window with information that EmployDB.exe has encountered a 
problem and needs to close. More over the same source code works with 
DEV-CPP (mingw) very good !!!

Can some one put on this some loght ? Maybe I need to specyfy some kind 
of information for compiler/linker ?

Best Regards,
Fibre Optic
Jul 07 2005
parent reply "Walter" <newshound digitalmars.com> writes:
What I'd do is look at Database.cpp lines 48 & 60 and see if there's a
problem with the return statement of the functions. You might also check to
see if there is an author's web page for that book (there usually is for
programmer books), and what if any errata there are. From that, you might
also contact the author for help debugging his program.

It's not a good idea to use embedded spaces, +'s, or -'s in path names for
DM (the linker gets confused). Just put it in the default c:\dm directory.

And lastly, I'd not turn on compiler optimizer switches until the program is
debugged and running. Why is -gp on? Why -s? Why -r? Compile with -g. Then
run under the debugger, that'll show you where the error happened.


"Fibre Optic" <fibre_optic go2.pl> wrote in message
news:dajsvs$1l3r$1 digitaldaemon.com...
 Hello,

 i am trying to pleay with example from such a book: Professional C++
 (Programmer to Programmer). After compilation I have such output:

 sc Database.cpp -cpp -Ae -r -mn -o+time -WA -s -3 -a8 -c -gp
 -D_CONSOLE=1 -IC:\DM-cpp\stlport\stlport -oDatabase.obj
 Warning: C:\Dev-Cpp\Projects\C++\EmployeeDB\Database.cpp(48): implied
 return of Records::Database::getEmployee at closing '}' does not return
 value
 Warning: C:\Dev-Cpp\Projects\C++\EmployeeDB\Database.cpp(60): implied
 return of Records::Database::getEmployee at closing '}' does not return
 value
 sc Employee.cpp -cpp -Ae -r -mn -o+time -WA -s -3 -a8 -c -gp
 -D_CONSOLE=1 -IC:\DM-cpp\stlport\stlport -oEmployee.obj
 sc UserInterface.cpp -cpp -Ae -r -mn -o+time -WA -s -3 -a8 -c -gp
 -D_CONSOLE=1 -IC:\DM-cpp\stlport\stlport -oUserInterface.obj
 link /NOI /DE /PACKF /XN /NT /ENTRY:mainCRTStartup /BAS:4194304 /A:512
  EmployeeDB.LNK
 ren .\$SCW$.EXE EmployeeDB.EXE
 .\EmployeeDB.EXE built
 Lines Processed: 52508  Errors: 0  Warnings: 2
 Successful build


 So, it looks ok. but after start up on screen I see menu in console
 window (this is ok.) but when I chose option i.e. 0-6 I see new M$
 Windows like window with information that EmployDB.exe has encountered a
 problem and needs to close. More over the same source code works with
 DEV-CPP (mingw) very good !!!

 Can some one put on this some loght ? Maybe I need to specyfy some kind
 of information for compiler/linker ?

 Best Regards,
 Fibre Optic

Jul 07 2005
parent reply Fibre Optic <fibre_optic go2.pl> writes:
Walter wrote:
 What I'd do is look at Database.cpp lines 48 & 60 and see if there's a
 problem with the return statement of the functions. You might also check to
 see if there is an author's web page for that book (there usually is for
 programmer books), and what if any errata there are. From that, you might
 also contact the author for help debugging his program.
 
 It's not a good idea to use embedded spaces, +'s, or -'s in path names for
 DM (the linker gets confused). Just put it in the default c:\dm directory.
 
 And lastly, I'd not turn on compiler optimizer switches until the program is
 debugged and running. Why is -gp on? Why -s? Why -r? Compile with -g. Then
 run under the debugger, that'll show you where the error happened.
 
 

ok. the code is simple: #include <iostream> using namespace std; int displayMenu(); int main(int argc, char** argv) { bool done = false; while (!done) { int selection = displayMenu(); switch (selection) { case 1: ; break; case 2: ; break; case 0: done = true; break; default: cerr << "Unknown command." << endl; } } } int displayMenu() { int selection; cout << endl; cout << "Employee Database" << endl; cout << "-----------------" << endl; cout << "1) Hire a new employee" << endl; cout << "2) Fire an employee" << endl; cout << "0) Quit" << endl; cout << endl; cout << "---> "; cin >> selection; return selection; } Could you please check this with your instalation of DM ? BTW I have DigitalMars.-.C++.8.40.-.Distribution CD upgraded to most recent version and upgreded STL Port (http://mordred.cs.ucla.edu/STLport_DMC) Thanks a lot ! Fibre Optic
Jul 07 2005
next sibling parent reply Cesar Rabak <crabak acm.org> writes:
Fibre Optic escreveu:
 Walter wrote:
 
 What I'd do is look at Database.cpp lines 48 & 60 and see if there's a
 problem with the return statement of the functions. You might also 
 check to


 
 ok. the code is simple:
 

 
 
 Could you please check this with your instalation of DM ?

Could you please check if this is indeed the code that for Database.cpp? The code you sent does not have even a 48th line, so no error could have ocurred at lines 48 and 60! -- Cesar Rabak
Jul 07 2005
parent Fibre Optic <fibre_optic go2.pl> writes:
Cesar Rabak wrote:
 
 Could you please check if this is indeed the code that for Database.cpp? 
 The code you sent does not have even a 48th line, so no error could have 
 ocurred at lines 48 and 60!
 
 -- 
 Cesar Rabak

you have right, I cut few lines because due to size of code. Source code I sent in my last e-mail generates the same problem during execute ( during compilation/link there is no errors/warnings) Once again, this source code with DEV-CPP (mingw) works fine. Regards, Fibre Optic
Jul 07 2005
prev sibling parent "Walter" <newshound digitalmars.com> writes:
"Fibre Optic" <fibre_optic go2.pl> wrote in message
news:dak8qh$1t7g$1 digitaldaemon.com...
 Could you please check this with your instalation of DM ?

Seems to work fine: --------------------------------------------------- C:\cbx>sc test -I\dm\stlport\stlport link test,,,user32+kernel32/noi; C:\cbx>test Employee Database ----------------- 1) Hire a new employee 2) Fire an employee 0) Quit ---> 1 Employee Database ----------------- 1) Hire a new employee 2) Fire an employee 0) Quit ---> 2 Employee Database ----------------- 1) Hire a new employee 2) Fire an employee 0) Quit ---> 0 C:\cbx>
Jul 08 2005