Code::Blocks
November 23, 2014, 09:08:01 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: When registered with our forums, feel free to send a "here I am" post in http://forums.codeblocks.org/index.php/topic,14168.0.html to differ human beings from SPAM bots.
 
   Home   Help Search Login Register  :: WebsiteWiki  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: I Cant run Viasual C++ project from code::blocks  (Read 2267 times)
rain-13
Newcomer
*
Offline Offline

Posts: 5


« on: May 21, 2009, 05:30:38 pm »

If I compile my source in MS Visual C++, my source runs perfectly,But When I Try compile my source with code::Blocks I get some errors.I have tried to copy some files from VC++ include dir to C::B includes dir, but it didn't help.
When I select VC++ compiler from compilers list, Code::Blocks don't even try to compile it.How I could compile that code with C::B ?
If I installed platform SDK for VC++ then how I use it with C::B?

VC++ Win32Console app

Code:
#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <string> 

using namespace std; 
 
void GenerateCombinKey(WORD *keys) 

    int n = sizeof(keys) / sizeof(WORD); 
    for(int i = 0; i < n; i++) 
    { 
        INPUT input = {0}; 
        input.type = INPUT_KEYBOARD; 
        input.ki.wVk  = keys[i]; 
        SendInput(1, &input, sizeof(input)); 
    } 
    for(int i = n - 1; i >= 0; i--) 
    { 
        INPUT input = {0}; 
        input.type = INPUT_KEYBOARD; 
        input.ki.wVk  = keys[i]; 
        input.ki.dwFlags = KEYEVENTF_KEYUP; 
        SendInput(1, &input, sizeof(input)); 
    } 

 
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) 

    WCHAR winText[50]; 
    GetWindowText(hwnd, winText, 50); 
    if (!wcsncmp(winText, (WCHAR*)lParam, 50)) 
    { 
        RECT rect; 
        GetWindowRect(hwnd, &rect); 
        INPUT input[3]; 
        memset(input,0,sizeof(INPUT)); 
        input[0].type = INPUT_MOUSE; 
        input[0].mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE; 
        input[0].mi.dx = (rect.left + 25) * (65535 / 1280); 
        input[0].mi.dy = (rect.top + 15) * (65535 / 1024); 
        input[1].type = INPUT_MOUSE; 
        input[1].mi.dwFlags = MOUSEEVENTF_LEFTDOWN; 
        input[2].type = INPUT_MOUSE; 
        input[2].mi.dwFlags = MOUSEEVENTF_LEFTUP; 
        SendInput(3, input, sizeof(INPUT)); 
    } 
 
    return TRUE; 

 
void SendString(LPCTSTR str) 

    INPUT inp[2]; 
    memset(inp,0,sizeof(INPUT)); 
    inp[0].type = INPUT_KEYBOARD; 
    inp[0].ki.dwFlags = KEYEVENTF_UNICODE; // to avoid shift, etc. 
    inp[1] = inp[0]; 
    inp[1].ki.dwFlags |= KEYEVENTF_KEYUP; 
 
    for (LPCTSTR p=str; *p; p++) 
    { 
        inp[0].ki.wScan = inp[1].ki.wScan = *p; 
        SendInput(2, inp, sizeof(INPUT)); 
    } 

 
int main()

    system("start c:\\Windows\\System32\\notepad.exe"); 
    Sleep( 1000 ); 
    HWND GameWindow = FindWindow(NULL, L"Untitled - Notepad"); 
    if(GameWindow != NULL) 
    { 
        SetWindowPos(GameWindow, 
            HWND_TOP, 
            0, 
            0, 
            0, 
            0, 
            SWP_NOSIZE); 
 
        SetForegroundWindow(GameWindow); 
        for ( int x = 0; x < 10; x++ ) 
        { 
            SendString(L"ABCabc123!(=#+-/\.,\n"); 
        } 
        Sleep(1000); 
        WORD combinKeys[] = {VK_LMENU, VK_F4}; 
        GenerateCombinKey(combinKeys); 
        Sleep(1000); 
        HWND hWnd = FindWindow(L"#32770", L"Notepad"); 
        if(hWnd != NULL) 
        { 
            EnumChildWindows(hWnd, EnumChildProc, (LPARAM)L"&No");  // "&Save" is Save button
        } 
    }
    return 0;
}

In code::blocks I see.
Code:
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|203|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|204|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|205|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|206|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|217|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|219|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|221|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|223|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|447|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|448|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|449|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|450|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|482|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|484|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|486|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\stdio.h|488|error: `__gnuc_va_list' has not been declared|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\mingw32\bits\c++locale.h||In function `int std::__convert_from_v(char*, int, const char*, _Tv, int* const&, int)':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\mingw32\bits\c++locale.h|72|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h||In member function `_InIter std::num_get<_CharT, _InIter>::get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, bool&) const':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h|1974|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h||In member function `_InIter std::num_get<_CharT, _InIter>::get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, long int&) const':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h|2010|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h||In member function `_InIter std::num_get<_CharT, _InIter>::get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, short unsigned int&) const':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h|2015|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h||In member function `_InIter std::num_get<_CharT, _InIter>::get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, unsigned int&) const':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h|2020|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h||In member function `_InIter std::num_get<_CharT, _InIter>::get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, long unsigned int&) const':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h|2025|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h||In member function `_InIter std::num_get<_CharT, _InIter>::get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, long long int&) const':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h|2031|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h||In member function `_InIter std::num_get<_CharT, _InIter>::get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, long long unsigned int&) const':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h|2036|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h||In member function `_InIter std::num_get<_CharT, _InIter>::get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, float&) const':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h|2069|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h||In member function `_InIter std::num_get<_CharT, _InIter>::get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, double&) const':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h|2074|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h||In member function `_InIter std::num_get<_CharT, _InIter>::get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, long double&) const':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h|2079|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h||In member function `_InIter std::num_get<_CharT, _InIter>::get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, void*&) const':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\locale_facets.h|2111|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\ostream||In function `std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char)':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\ostream|449|error: expected primary-expression before '<<' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\ostream|449|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\ostream||In function `std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char)':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\ostream|460|error: expected primary-expression before '<<' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\ostream||In function `std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char)':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\ostream|465|error: expected primary-expression before '<<' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\ostream||In function `std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*)':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\ostream|499|error: expected primary-expression before '<<' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\ostream||In function `std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*)':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\ostream|504|error: expected primary-expression before '<<' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc||In function `std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, _CharT)':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|481|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|488|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|488|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|492|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|493|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|496|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc||In function `std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char)':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|512|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|518|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|518|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|522|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|523|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|526|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc||In function `std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const _CharT*)':|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|541|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|548|error: expected primary-expression before ',' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|548|error: expected primary-expression before '.' token|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\c++\3.4.5\bits\ostream.tcc|553|error: expected primary-expression before '.' token|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|


« Last Edit: May 21, 2009, 05:32:54 pm by rain-13 » Logged
MortenMacFly
Administrator
Lives here!
*****
Offline Offline

Posts: 8687



« Reply #1 on: May 21, 2009, 07:00:51 pm »

When I Try compile my source with code::Blocks I get some errors.
Mixing VC++ with MinGW/GCC headers/libs is very dangerous. Most likely you did destroy your MinGW/GCC installation already. You cannot mix "stuff" from different compilers (easily).
I realised you are using AFX headers, so you have two choices:
1.) stay with VC++ -> setup C::B to use the VC compiler as described in detail in the WiKi and here in the forums (do a search).
2.) convert your sources not to use AFX and use MinGW/GCC - but a fresh installation of the compiler suite as yours is most likely damaged.
Logged

Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!