Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: Date: Mon, 28 Oct 2002 23:36:17 +1900 From: Mark Schoenberg To: cygwin AT cygwin DOT com Subject: Re: Problem compiling cpp programs with gcc-3.2-1 Dear Danny, Thank you for your rapid and thorough reply. Here is the slighly more sophisticated program which just pops up a window and exits upon IDCANCEL. The compilation output to the command gcc -O2 -mno-cygwin -mwindows short.cpp \ -lkernel32 -luser32 -lgdi32 -lwinspool \ -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 \ anv.res -o short is NULL under 2.95.3-5. (i.e. perfect compilation without warnings). The compilation output under 3.2.1-1 is /DOCUME~1/Mark/LOCALS~1/Temp/ccpKyX2E.o(.text+0x2f8):short.cpp: undefined reference to `operator new(unsigned)' /DOCUME~1/Mark/LOCALS~1/Temp/ccpKyX2E.o(.text+0x329):short.cpp: undefined reference to `__cxa_begin_catch' /DOCUME~1/Mark/LOCALS~1/Temp/ccpKyX2E.o(.text+0x355):short.cpp: undefined reference to `__cxa_end_catch' /DOCUME~1/Mark/LOCALS~1/Temp/ccpKyX2E.o(.text+0x367):short.cpp: undefined reference to `__cxa_begin_catch' /DOCUME~1/Mark/LOCALS~1/Temp/ccpKyX2E.o(.text+0x39d):short.cpp: undefined reference to `__cxa_end_catch' /DOCUME~1/Mark/LOCALS~1/Temp/ccpKyX2E.o(.text+0x3aa):short.cpp: undefined reference to `operator delete(void*)' /DOCUME~1/Mark/LOCALS~1/Temp/ccpKyX2E.o(.text+0x3bf):short.cpp: undefined reference to `__cxa_end_catch' /DOCUME~1/Mark/LOCALS~1/Temp/ccpKyX2E.o(.data$_ZTI12WinException+0x0):short.cpp: undefined reference to `vtable for __cxxabiv1::__class_type_info' /DOCUME~1/Mark/LOCALS~1/Temp/ccpKyX2E.o(.eh_frame+0x12):short.cpp: undefined reference to `__gxx_personality_v0' make: *** [short] Error 1 --Mark -------------------------------------------------------------------------------- /*Program short.cpp*/ #include #ifndef _MAIN_H_INCLUDED #define _MAIN_H_INCLUDED #ifndef _CONTROLS_H_INCLUDED #define _CONTROLS_H_INCLUDED class SimpleControl { public: SimpleControl (HWND hwndParent, int id, BOOL initialState=TRUE) : _hWnd (GetDlgItem (hwndParent, id)) { if (initialState == FALSE) Disable(); } void Hide () { ::ShowWindow(_hWnd , SW_HIDE); } void Show () { ::ShowWindow(_hWnd , SW_SHOW); } BOOL IsVisible() { return(::IsWindowVisible(_hWnd )); } void SetFocus () { ::SetFocus (_hWnd); } void Enable() { ::EnableWindow(_hWnd , TRUE); } void Disable() { ::EnableWindow(_hWnd , FALSE); } HWND Hwnd () const { return _hWnd; } protected: HWND _hWnd; }; class Button : public SimpleControl { public: Button(HWND hwndParent, int id, BOOL initialState=TRUE) : SimpleControl(hwndParent, id, initialState) {} void SetName( char const * newName ) { SendMessage(_hWnd, WM_SETTEXT, 0, (LPARAM)newName ); } }; class CheckBox : public Button { public: CheckBox (HWND hwndParent, int id, BOOL initialState=TRUE) : Button(hwndParent, id, initialState) {} BOOL IsChecked() { return( SendMessage(_hWnd, BM_GETCHECK, 0, 0) == BST_CHECKED ); } void Check() { SendMessage( _hWnd, BM_SETCHECK, (WPARAM) BST_CHECKED, 0); } void UnCheck() { SendMessage( _hWnd, BM_SETCHECK, (WPARAM) BST_UNCHECKED, 0); } }; class RadioButton: public Button { public: RadioButton (HWND hwndParent, int id, BOOL initialState=TRUE) : Button(hwndParent, id, initialState) {} BOOL IsSelected() { return( SendMessage( _hWnd, BM_GETCHECK, 0, 0) == BST_CHECKED ); } void Select() { SendMessage( _hWnd, BM_SETCHECK, (WPARAM) BST_CHECKED, 0); } }; class Edit: public SimpleControl { public: Edit (HWND hwndParent, int id, BOOL initialState=TRUE) : SimpleControl (hwndParent, id, initialState) {} void SetString (char* buf) { SendMessage (_hWnd, WM_SETTEXT, 0, (LPARAM) buf); } // code is the HIWORD (wParam) static BOOL IsChanged (int code) { return code == EN_CHANGE; } int GetLength () { return (int)(SendMessage (_hWnd, WM_GETTEXTLENGTH, 0, 0)); } void GetString (char* buf, int len) { SendMessage (_hWnd, WM_GETTEXT, (WPARAM) len, (LPARAM) buf); } void Select () { SendMessage (_hWnd, EM_SETSEL, 0, -1); } void ClearSelection () { // SendMessage (_hWnd, EM_SETSEL, -1, 0); SendMessage (_hWnd, EM_SETSEL, 1, 0); } }; #endif // _CONTROLS_H_INCLUDED class WinException { public: WinException (char* msg) : _err (GetLastError()), _msg(msg) {} DWORD GetError() const { return _err; } char* GetMessage () const { return _msg; } private: DWORD _err; char* _msg; }; class Controller { public: Controller(HWND hwnd); ~Controller () {} void Command (HWND hwnd, int controlID, int command); private: Edit _status; Button _button1; Button _button2; }; #define DLG_MainDialog 1124 #define MSG_SIZ 512 #endif // _MAIN_H_INCLUDED #ifndef _RC_H_INCLUDED #define _RC_H_INCLUDED #define DLG_MAIN 200 #define DLG_ICON 300 #define DLG_ICON_S 301 #define IDC_STATUS 1000 #define IDC_LEFT 1001 #define IDC_RIGHT 1002 #define IDC_TOP 1003 #define IDC_MIDDLE 1004 #define IDC_BOTTOM 1005 #define IDC_BUTTON1 1007 #define IDC_BUTTON2 1008 #define IDC_BUTTON3 1009 #define IDC_EDIT 1010 #define IDC_CLEAR 1011 #define IDC_STATIC -1 #endif // _RC_H_INCLUDED HINSTANCE TheInstance = 0, hInst; void PopUpMainDialog(void); LRESULT CALLBACK HandleMainDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, char * cmdParam, int cmdShow) { TheInstance = hInst; HWND hDialog = 0; PopUpMainDialog(); //I have no idea what code below does MSG msg; int status; while ((status = GetMessage (&msg, 0, 0, 0)) != 0) { if (status == -1) return -1; if (!IsDialogMessage (hDialog, &msg)) { TranslateMessage ( &msg ); DispatchMessage ( &msg ); } } return msg.wParam; } //End WinMain Controller::Controller (HWND hwnd) : _status (hwnd, IDC_STATUS), _button1 (hwnd, IDC_BUTTON1), _button2 (hwnd, IDC_BUTTON2) { // Attach icon to main dialog HICON hIcon = LoadIcon (TheInstance, MAKEINTRESOURCE (DLG_ICON)); SendMessage (hwnd, WM_SETICON, WPARAM (TRUE), LPARAM (hIcon)); hIcon = LoadIcon (TheInstance, MAKEINTRESOURCE (DLG_ICON_S)); SendMessage (hwnd, WM_SETICON, WPARAM (FALSE), LPARAM (hIcon)); } void Controller::Command (HWND hwnd, int controlID, int command) { char statusMessage[64]; char buffer[800], remindtext[800]; int i, n; switch (controlID) { case IDC_BUTTON1: if (command == BN_CLICKED) { } break; case IDC_BUTTON2: if (command == BN_CLICKED) { PostQuitMessage(0); } break; } } BOOL CALLBACK DialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static Controller* control = 0; //extern char lockfile[100]; switch (message) { case WM_INITDIALOG: try { control = new Controller (hwnd); } catch (WinException e) { MessageBox (0, e.GetMessage (), "Exception", MB_ICONEXCLAMATION | MB_OK); } catch (...) { MessageBox (0, "Unknown", "Exception", MB_ICONEXCLAMATION | MB_OK); return -1; } return TRUE; case WM_COMMAND: control->Command(hwnd, LOWORD(wParam), HIWORD (wParam)); return TRUE; } return FALSE; } //End DialogProc void PopUpMainDialog(void) { FARPROC lpProc; lpProc = MakeProcInstance((FARPROC)HandleMainDialog, hInst); DialogBox(hInst, MAKEINTRESOURCE(DLG_MainDialog), NULL, (DLGPROC)lpProc); FreeProcInstance(lpProc); //return 0; } // Process messages for MainDialog dialog box LRESULT CALLBACK HandleMainDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { char buf[MSG_SIZ]; HWND hwndCombo; switch (message) { case WM_INITDIALOG: break; case WM_COMMAND: // message: received a command switch (LOWORD(wParam)) { case IDCANCEL: //MainDialog PostQuitMessage( 0); return FALSE; break; default: //MainDialog break; } //End switch (LOWARD) } //End switch (message) return FALSE; } //End HandleMainDialog -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/