Code::Blocks

User forums => Using Code::Blocks => Topic started by: vishalonne on November 11, 2012, 06:27:20 pm

Title: CodeBlock cannot find header file
Post by: vishalonne on November 11, 2012, 06:27:20 pm
I started learning CodeBlock from yesterday and I want to use MinGW compiler with it. How can I use MinGW with CodeBlock. I asked this question because. I am testing a database connection program in C. I include these files this way in CodeBlock
Setting->Linker Setting-Add
C:\SQLAPI\lib\libsqlapiddll.a 
C:\MinGW\lib\libuser32.a
C:\MinGW\lib\libversion.a
C:\MinGW\lib\liboleaut32.a
C:\MinGW\lib\libole32.a

And this is the code but it is giving error - C:\MinGW\lib\cppmsql.c   2   fatal error: SQLAPI.h: No such file or directory
c Code -
Code: [Select]
#include <stdio.h>  // for printf
#include <SQLAPI.h> // main SQLAPI++ header
int main(int argc, char* argv[])
{
    SAConnection con; // create connection object
      try
    {
        con.Connect(
            "localhost:[email protected]",     // database name
            "root",   // user name
            "");   // password
                  //optional client name not provided
        printf("We are connected!\n");
        con.Disconnect();
        printf("We are disconnected!\n");
    }
    catch(SAException &x)
    {
        try
        {
            con.Rollback();
        }
        catch(SAException &)
        {
        }
        printf("%s\n", (const char*)x.ErrText());
    }
     return 0;
}

How can solve this problem. Thanx in advance for any suggestion or guidance
Title: Re: CodeBlock cannot find header file
Post by: oBFusCATed on November 11, 2012, 06:39:06 pm
You have to setup include search paths.
Title: Re: CodeBlock cannot find header file
Post by: vishalonne on November 11, 2012, 06:51:03 pm
I am just 1 user og codeblock I don't know how to setup include search path. Please guide me
Title: Re: CodeBlock cannot find header file
Post by: stahta01 on November 11, 2012, 06:53:42 pm
I am just 1 user og codeblock I don't know how to setup include search path. Please guide me

Read http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F)

Use the "For your project" option it is better in nearly all cases.

Tim S.
Title: Re: CodeBlock cannot find header file
Post by: vishalonne on November 11, 2012, 07:07:04 pm
AS per documentation under the For your Project option 1st step is - Right click on the project then select Build options but unfortunately I am not getting this option. I'm using CodeBlock 10.05

Title: Re: CodeBlock cannot find header file
Post by: oBFusCATed on November 11, 2012, 07:32:41 pm
Do you have a project?
Title: Re: CodeBlock cannot find header file
Post by: vishalonne on November 11, 2012, 07:36:27 pm
No I simply created a New File and saved it as cppmsql.c after writing the above code and adding the libraries which I mentioned in my post. And compiler is GNU GCC compiler
Title: Re: CodeBlock cannot find header file
Post by: oBFusCATed on November 11, 2012, 07:38:49 pm
Then create a project.
Title: Re: CodeBlock cannot find header file
Post by: vishalonne on November 11, 2012, 07:54:59 pm
Yes now I have a c console project and a file named as main.c which is default. And I also added the code but still same error
Title: Re: CodeBlock cannot find header file
Post by: oBFusCATed on November 11, 2012, 08:09:35 pm
Is this header present at all?
Have you carefully read the posted link and/or the other bullets in the FAQ?
Title: Re: CodeBlock cannot find header file
Post by: vishalonne on November 11, 2012, 08:31:36 pm
yes header file is present under C:\SQLAPI\include
Title: Re: CodeBlock cannot find header file
Post by: oBFusCATed on November 11, 2012, 08:47:35 pm
Then you know the path, just add it in the project build options...
Title: Re: CodeBlock cannot find header file
Post by: vishalonne on November 11, 2012, 09:11:34 pm
pls see the attached screen shot, I'm I on correct way

[attachment deleted by admin]
Title: Re: CodeBlock cannot find header file
Post by: oBFusCATed on November 11, 2012, 10:06:33 pm
pls see the attached screen shot, I'm I on correct way
No, because you don't make a difference between a compiler and linker errors.

Make sure you read this: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
carefully and understand it! Until then you won't progress much.
Title: Re: CodeBlock cannot find header file
Post by: vishalonne on November 11, 2012, 11:18:51 pm
Thankx a lot for your guidance. program is compiled successfully. But Now next problem is standing in front of me.
On compilation I am getting this message
Quote
-------------- Build: Debug in database ---------------

Compiling: main.cpp
Linking console executable: bin\Debug\database.exe
Output size is 38.12 KB
Process terminated with status 0 (0 minutes, 1 seconds)
0 errors, 0 warnings

But when I run the program it opens a error message dialog box -
Quote
The program can't start because libsqlapid.dll is missing from your computer. Try reinstalling the program to fix this problem.
I made all the setups for linker which is C:\SQLAPI\lib\libsqlapiddll.a from build option
Guide me please
Title: Re: CodeBlock cannot find header file
Post by: oBFusCATed on November 11, 2012, 11:30:15 pm
Copy the dll. Also read and understand how dynamic linked libraries work in windows. MSDN has probably a pretty good article about it.