Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What Am I doing Wrong? 2

Status
Not open for further replies.

jamez05

Programmer
Jul 29, 2005
130
US
Hi,

I'm trying to call a dll from a simple win32 console application. It works in the sample windows app that was sent with the 3rd party dll, but I can't get it to work in a simple "Hello World" App I'm writing.

The function calls and variables are copied word for word from the working example app. I'm using Visual Studio 2005. Here's the steps I've taken:

1. Created a Win 32 console app named Biowwin.
2. Built the solution
3. Placed BIOWDLL.lib in the Biowwin folder with the other source code.
4. Placed biowdll.dll into the Biowwin/debug folder where biowwin.exe is located.
5. Created the following code:

Code:
// Biowwin.cpp : Defines the entry point for the console application.
//

#include <windows.h>
#include "stdafx.h"
#include <stdio.h>
#include <string.h>

__declspec ( dllexport )int WINAPI GetSrcBIOWIN (PSTR cSmilePass,
   PSTR cChemical, PSTR EstLin, PSTR EstNon, PSTR EstUlt, PSTR EstPrim,
   PSTR UltTime, PSTR PrimTime, PSTR EstMitiLin, PSTR EstMitiNon,
   PSTR DetailResults, PSTR numLines, PSTR ErrorMess);


char EstLin[15];
char EstNon[15];
char EstUlt[15];
char EstPrim[15];
char EstMitiLin[15];
char EstMitiNon[15];
char UltTime[30];
char PrimTime[30];
char Details[12000];
char ErrMess[1200];
char numLines[12];

int _tmain(int argc, _TCHAR* argv[])
{

	int Ret1 = GetSrcBIOWIN("O=C","ChemName",
               EstLin,EstNon,EstUlt,EstPrim,
               UltTime,PrimTime,EstMitiLin,EstMitiNon,
               Details,numLines,ErrMess);

	return 0;
}

When I try to build it, I get the following errors:
Code:
------ Build started: Project: Biowwin, Configuration: Debug Win32 ------
Compiling...
Biowwin.cpp
c:\documents and settings\epajn\my documents\visual studio 2005\projects\biowwin\biowwin\biowwin.cpp(9) : error C2146: syntax error : missing ';' before identifier 'GetSrcBIOWIN'
c:\documents and settings\epajn\my documents\visual studio 2005\projects\biowwin\biowwin\biowwin.cpp(9) : error C2065: 'PSTR' : undeclared identifier
c:\documents and settings\epajn\my documents\visual studio 2005\projects\biowwin\biowwin\biowwin.cpp(9) : error C2146: syntax error : missing ')' before identifier 'cSmilePass'
c:\documents and settings\epajn\my documents\visual studio 2005\projects\biowwin\biowwin\biowwin.cpp(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\epajn\my documents\visual studio 2005\projects\biowwin\biowwin\biowwin.cpp(12) : error C2059: syntax error : ')'
c:\documents and settings\epajn\my documents\visual studio 2005\projects\biowwin\biowwin\biowwin.cpp(33) : error C2064: term does not evaluate to a function taking 13 arguments
Build log was saved at "file://c:\Documents and Settings\epajn\My Documents\Visual Studio 2005\Projects\Biowwin\Biowwin\Debug\BuildLog.htm"
Biowwin - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I've been struggling with this for awhile. Any help is appreciated.
 
> #include "stdafx.h"
I thought this had to be the first include in any file, since it is used by the precompiled headers abomination.

So
[tt]
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <string.h>
[/tt]

--
 
Thanks Salem!!!!

That got rid of the majority of the errors. Learned something new (learning as I go).
 
Additional advice (sorry, Salem;):
Place all includes
Code:
#include <windows.h>
#include <cstdio>
#include <cstring>
in stdafx.h (see TODO tip in the header) then recompile stdafx.cpp to precompile huge header windows.h et al). Now you may include stdafx.h only in sources (cstdio instead of stdio.h etc: you have cpp (C++) source).
Use 100% precompiled headers speed...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top