I need to call to SEVERAL functions that are inside the EXE from a DLL location. And, I also will need to access some of the variables found inside the EXE from the DLL. Below is the error list, probably not helpful at all, but attached it anyway.
I did the opposite (exe->dll) by using .def files and dllimport and additional dependencies. And, now I am stuck needing to the other way around.
note: Micros*t Visual Studio 2008 pro, Standard-C.
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_GentityNum が関数 _SV_BotAllocateClient で参照されました。
3>sv_bot.obj : error LNK2001: 外部シンボル "_svs" は未解決です。
3>sv_bot.obj : error LNK2001: 外部シンボル "_sv_maxclients" は未解決です。
3>sv_bot.obj : error LNK2001: 外部シンボル "_botlib_export" は未解決です。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Cvar_Get が関数 _BotDrawDebugPolygons で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_Trace が関数 _BotImport_Trace で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_ClipToEntity が関数 _BotImport_EntityTrace で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_PointContents が関数 _BotImport_PointContents で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_inPVS が関数 _BotImport_inPVS で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _CM_EntityString が関数 _BotImport_BSPEntityData で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _CM_ModelBounds が関数 _BotImport_BSPModelMinsMaxsOrigin で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _CM_InlineModel が関数 _BotImport_BSPModelMinsMaxsOrigin で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Z_TagMalloc が関数 _BotImport_GetMemory で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Z_Free が関数 _BotImport_FreeMemory で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Hunk_Alloc が関数 _BotImport_HunkAlloc で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Hunk_CheckMark が関数 _BotImport_HunkAlloc で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _SV_ExecuteClientCommand が関数 _BotClientCommand で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _VM_Call が関数 _SV_BotFrame で参照されました。
3>sv_bot.obj : error LNK2001: 外部シンボル "_gvm" は未解決です。
2> ライブラリ ..\..\build\quake3_release\ioquake3.lib とオブジェクト ..\..\build\quake3_release\ioquake3.exp を作成中
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _GetBotLibAPI が関数 _SV_BotInitBotLib で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _FS_Seek が関数 _SV_BotInitBotLib で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _FS_FCloseFile が関数 _SV_BotInitBotLib で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _FS_Write が関数 _SV_BotInitBotLib で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _FS_Read2 が関数 _SV_BotInitBotLib で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _FS_FOpenFileByMode が関数 _SV_BotInitBotLib で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Z_AvailableMemory が関数 _SV_BotInitBotLib で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Z_Malloc が関数 _SV_BotInitBotLib で参照されました。
3>sv_bot.obj : error LNK2019: 未解決の外部シンボル _Cvar_VariableIntegerValue が関数 _SV_BotInitBotLib で参照されました。
3>..\..\build\game_release\qagamex86.dll : fatal error LNK1120: 外部参照 28 が未解決です。
2>LINK : warning LNK4098: defaultlib 'LIBCMT' は他のライブラリの使用と競合しています。/NODEFAULTLIB:library を使用してください。
3>ビルドログは "file://c:\Documents and Settings\yasir\デスクトップ\ioquake3dev\ioquake3dev - sandbox\build\game_release\BuildLog.htm" に保存されました。
3>game - エラー 29、警告 0
2>LINK : warning LNK4199: /DELAYLOAD:OleAcc.dll は無視されます。OleAcc.dll にインポートがありません。
2>cm_patch.obj : error LNK2019: 未解決の外部シンボル _BotDrawDebugPolygons が関数 _CM_DrawDebugSurface で参照されました。
2>sv_client.obj : error LNK2019: 未解決の外部シンボル _SV_BotFreeClient が関数 _SV_DropClient で参照されました。
2>sv_game.obj : error LNK2001: 外部シンボル "_SV_BotFreeClient" は未解決です。
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _SV_BotGetConsoleMessage が関数 _SV_GameSystemCalls で参照されました。
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _SV_BotGetSnapshotEntity が関数 _SV_GameSystemCalls で参照されました。
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _SV_BotLibShutdown が関数 _SV_GameSystemCalls で参照されました。
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _SV_BotLibSetup が関数 _SV_GameSystemCalls で参照されました。
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _BotImport_DebugPolygonDelete が関数 _SV_GameSystemCalls で参照されました。
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _BotImport_DebugPolygonCreate が関数 _SV_GameSystemCalls で参照されました。
2>sv_game.obj : error LNK2019: 未解決の外部シンボル _SV_BotAllocateClient が関数 _SV_GameSystemCalls で参照されました。
2>sv_game.obj : error LNK2001: 外部シンボル "_bot_enable" は未解決です。
2>sv_init.obj : error LNK2019: 未解決の外部シンボル _SV_BotFrame が関数 _SV_SpawnServer で参照されました。
2>sv_main.obj : error LNK2001: 外部シンボル "_SV_BotFrame" は未解決です。
2>sv_init.obj : error LNK2019: 未解決の外部シンボル _SV_BotInitBotLib が関数 _SV_Init で参照されました。
2>sv_init.obj : error LNK2019: 未解決の外部シンボル _SV_BotInitCvars が関数 _SV_Init で参照されました。
2>..\..\build\quake3_release\ioquake3.exe : fatal error LNK1120: 外部参照 13 が未解決です。
2>ビルドログは "file://c:\Documents and Settings\yasir\デスクトップ\ioquake3dev\ioquake3dev - sandbox\build\quake3_release\BuildLog.htm" に保存されました。
2>quake3 - エラー 16、警告 2
========== ビルド: 0 正常終了、2 失敗、2 更新不要、1 スキップ ==========
I think you cannot link the DLL to your EXE. Instead define a struct which contains function pointers and initialize an instance of this struct in your exe. Assingn the pointers to your functions to the pointers in your struct instance. Call a DLL function to store a pointer to the struct instance in a static variable of your DLL. Whenever your DLL wants to call a EXE-function call this function using a function pointer from the struct instance.
Related
My project structure looks like this.
build
- folder where cmake outputs the solution file
client
- client.c
- CMakeLists.txt
server
- server.c
- CMakeLists.txt
open62541
- open62541.c
- open62541.h
- CMakeLists.txt
CMakeLists.txt
The main CMakeLists.txt has the following code
cmake_minimum_required(VERSION 3.0)
project(openstack)
add_subdirectory(open62541)
add_subdirectory(server)
open62541/CMakeLists.txt has the following code
project(Lib1)
add_library(lib1 open62541.c open62541.h)
and server/CMakeLists.txt looks like this
project(App)
add_executable(app server.c)
include_directories(${Lib1_SOURCE_DIR})
target_link_libraries(app PRIVATE lib1 ws2_32 wsock32)
server.c has the following code.
#include "open62541.h"
#include "signal.h"
#include <stdlib.h>
#include "stdio.h"
static volatile UA_Boolean running = true;
static void stopHandler(int sig) {
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "received ctrl-c");
running = false;
}
int main(void) {
signal(SIGINT, stopHandler);
signal(SIGTERM, stopHandler);
UA_Server *server = UA_Server_new();
UA_ServerConfig_setDefault(UA_Server_getConfig(server));
UA_StatusCode retval = UA_Server_run(server, &running);
UA_Server_delete(server);
return retval == UA_STATUSCODE_GOOD ? EXIT_SUCCESS : EXIT_FAILURE;
}
server.c needs functions defined and declared in open62541.c and open62541.h.(I am not building the client project as of now)So, I have included open62541.h in the server.c file and in the server/CMakeLists.txt, I have given the link to the open62541 folder as you can see. I am getting the following linker errors in visual studio. The message is in german sorry for that.
Erstellen gestartet...
1>------ Erstellen gestartet: Projekt: app, Konfiguration: Debug x64 ------
1>server.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp_UA_Server_delete" in Funktion "main".
1>server.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp_UA_Server_getConfig" in Funktion "main".
1>server.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp_UA_Server_run" in Funktion "main".
1>server.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp_UA_Server_new" in Funktion "main".
1>server.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp_UA_ServerConfig_setMinimalCustomBuffer" in Funktion "UA_ServerConfig_setMinimal".
1>server.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "__imp_UA_Log_Stdout" in Funktion "stopHandler".
1>C:\Users\acer\CMake_Project\build\server\Debug\app.exe : fatal error LNK1120: 6 nicht aufgelöste Externe
1>Die Erstellung des Projekts "app.vcxproj" ist abgeschlossen -- FEHLER.
2>------ Erstellen übersprungen: Projekt: ALL_BUILD, Konfiguration: Debug x64 ------
2>Für diese Projektmappenkonfiguration wurde kein zu erstellendes Projekt ausgewählt.
========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 2 aktuell, 1 übersprungen ==========
The project builds fine when I include server. c,open62541.c,open62541.h files in a single folder and use a single CMakeLists.txt file like this.
cmake_minimum_required(VERSION 3.0)
project(openstack)
set(SOURCES server.c open62541.c open62541.h)
add_executable(openstack ${SOURCES})
target_link_libraries(openstack PRIVATE ws2_32 wsock32)
However, I get errors when I try to structure my project in different folders. How can I solve these errors?
I've restructured your project a little to be more modern. See if this works and tell me what you get.
cmake_minimum_required(VERSION 3.15)
project(openstack LANGUAGES C)
add_subdirectory(open62541)
add_subdirectory(server)
# You didn't add_subdirectory client.
add_subdirectory(client)
open62541/CMakeLists.txt has the following code
add_library(lib1 STATIC)
target_sources(lib1 PRIVATE open62541.c open62541.h)
# Prefer to use public. To ease use of your library.
target_include_directores(lib1 PUBLIC ${CMAKE_CURRENT_LIST_DIR)
and server/CMakeLists.txt looks like this
add_executable(app)
target_sources(app PRIVATE server.c)
target_link_libraries(app PRIVATE lib1 ws2_32 wsock32)
I'm having a linker issue while using the tf library. Below is my callback. Without the only line in the callback there is no linker error. Please, find below the linker error itself.
void callback (const sensor_msgs::PointCloud2ConstPtr& input)
{
listener->waitForTransform("/world_base_link", (*input).header.frame_id, (*input).header.stamp, ros::Duration(5.0));
}
int main (int argc, char** argv)
{
ros::init(argc, argv, "subscriber");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/kinect2/depth/points", 1, callback);
ros::spin ();
}
Linker error:
Linking CXX executable range_image_border_extraction
CMakeFiles/range_image_border_extraction.dir/range_image_border_extraction.cpp.o: In function `callback(boost::shared_ptr<sensor_msgs::PointCloud2_<std::allocator<void> > const> const&)':
range_image_border_extraction.cpp:(.text+0x18c): undefined reference to `tf::Transformer::waitForTransform(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::Time const&, ros::Duration const&, ros::Duration const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const'
collect2: ld returned 1 exit status
make[2]: *** [range_image_border_extraction] Error 1
make[1]: *** [CMakeFiles/range_image_border_extraction.dir/all] Error 2
make: *** [all] Error 2
CMakeLists.txt:
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(range_image_border_extraction)
find_package(PCL 1.7 REQUIRED)
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(range_image_border_extraction range_image_border_extraction.cpp)
target_link_libraries(range_image_border_extraction ${PCL_LIBRARIES})
target_link_libraries(range_image_border_extraction ${catkin_LIBRARIES})
package.xml
<?xml version="1.0"?>
<package>
<name>ipa325_com_client</name>
<version>1.0.0</version>
<description>Simulation client side communication interface</description>
<license>BSD</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>control_msgs</build_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>ipa325_msgs</build_depend>
<build_depend>ipa325_com_msgs</build_depend>
<build_depend>message_generation</build_depend>
<run_depend>tf</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>control_msgs</run_depend>
<run_depend>geometry_msgs</run_depend>
<run_depend>ipa325_com_msgs</run_depend>
<run_depend>ipa325_msgs</run_depend>
<run_depend>message_runtime</run_depend>
<export></export>
</package>
Any ideas how to resolve this linker error?
I've seen the following code that takes a screenshot and saves it as jpg, I've managed to compile and run it as win32 CONSOLE application,
But when I tried to use the following code in A windowsForm/CLI (there is just a button that should take a screenshot) project, I got the following errors:
1>screenshoter.obj : warning LNK4248: unresolved typeref token (0100002C) for 'Gdiplus.GpCachedBitmap'; image may not run
1>screenshoter.obj : error LNK2028: unresolved token (0A000017) "extern "C" int __stdcall ReleaseDC(struct HWND__ *,struct HDC__ *)" (?ReleaseDC##$$J18YGHPAUHWND__##PAUHDC__###Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A000018) "extern "C" int __stdcall DeleteObject(void *)" (?DeleteObject##$$J14YGHPAX#Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A000019) "extern "C" int __stdcall BitBlt(struct HDC__ *,int,int,int,int,struct HDC__ *,int,int,unsigned long)" (?BitBlt##$$J236YGHPAUHDC__##HHHH0HHK#Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A00001A) "extern "C" void * __stdcall SelectObject(struct HDC__ *,void *)" (?SelectObject##$$J18YGPAXPAUHDC__##PAX#Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A00001B) "extern "C" struct HBITMAP__ * __stdcall CreateCompatibleBitmap(struct HDC__ *,int,int)" (?CreateCompatibleBitmap##$$J212YGPAUHBITMAP__##PAUHDC__##HH#Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A00001C) "extern "C" struct HDC__ * __stdcall CreateCompatibleDC(struct HDC__ *)" (?CreateCompatibleDC##$$J14YGPAUHDC__##PAU1##Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A00001D) "extern "C" int __stdcall GetSystemMetrics(int)" (?GetSystemMetrics##$$J14YGHH#Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2028: unresolved token (0A00001E) "extern "C" struct HDC__ * __stdcall GetDC(struct HWND__ *)" (?GetDC##$$J14YGPAUHDC__##PAUHWND__###Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall ReleaseDC(struct HWND__ *,struct HDC__ *)" (?ReleaseDC##$$J18YGHPAUHWND__##PAUHDC__###Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall DeleteObject(void *)" (?DeleteObject##$$J14YGHPAX#Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall BitBlt(struct HDC__ *,int,int,int,int,struct HDC__ *,int,int,unsigned long)" (?BitBlt##$$J236YGHPAUHDC__##HHHH0HHK#Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" void * __stdcall SelectObject(struct HDC__ *,void *)" (?SelectObject##$$J18YGPAXPAUHDC__##PAX#Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" struct HBITMAP__ * __stdcall CreateCompatibleBitmap(struct HDC__ *,int,int)" (?CreateCompatibleBitmap##$$J212YGPAUHBITMAP__##PAUHDC__##HH#Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" struct HDC__ * __stdcall CreateCompatibleDC(struct HDC__ *)" (?CreateCompatibleDC##$$J14YGPAUHDC__##PAU1##Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall GetSystemMetrics(int)" (?GetSystemMetrics##$$J14YGHH#Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
1>screenshoter.obj : error LNK2019: unresolved external symbol "extern "C" struct HDC__ * __stdcall GetDC(struct HWND__ *)" (?GetDC##$$J14YGPAUHDC__##PAUHWND__###Z) referenced in function "private: void __clrcall screenshoter::Form1::gdiscreen(void)" (?gdiscreen#Form1#screenshoter##$$FA$AAMXXZ)
Note: That I've included all the files needed
I looked up in MSDN, but I couldn't really understand the error messeges. Moreover, I had encountered similar messages in the past, i solved it but adding a .lib file
This time I tried adding, however it didn't solve the problem
#pragma comment( lib, "GdiPlus.lib" )
Those functions are declared in gdi32.lib - not gdiplus.lib - and some might be in user32.lib.
Those error messages mean that your code (or rather, the 'screenshooter' code) used 'symbols' (could be function names or variables, for instance) for which there is no code linked into the final binary.
To fix this, look up what libraries you need to link against for each of those symbols. For instance, GetDC appears to be defined in user32.lib, so make sure to link against that (possibly by using a #pragma directive as you did for GdiPlus.lib).
I'm trying to use Visual Studio 2008 since I had problems opening a file in XCode. I am new to VS, but these are the steps I took. I created a new project, selected Win32 Console Application, empty project. My code is:
// C_test.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
#include <stdlib.h>
int main(void )
{
printf("Hello");
FILE *filePtr;
filePtr = fopen( "test.txt", "r" );
if (filePtr == NULL)
{
fprintf(stderr, "Can't open \"test\"\n");
exit(EXIT_FAILURE);
}
else
{
int x;
printf("File open successful\n");
/* read one character at a time until EOF is reached */
while ((x = fgetc(filePtr)) != EOF)
{
//printf("%c", x);
fprintf(stderr, "%x\n",x);
}
}
fclose(filePtr);
system("pause");
return 0;
}
Something doesn't seem to be correct since my error list is:
>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(9) : error C2275: 'FILE' : illegal use of this type as an expression
1> c:\program files\microsoft visual studio 9.0\vc\include\stdio.h(69) : see declaration of 'FILE'
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(9) : error C2065: 'filePtr' : undeclared identifier
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(11) : error C2065: 'filePtr' : undeclared identifier
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(11) : warning C4047: '=' : 'int' differs in levels of indirection from 'FILE *'
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(12) : error C2065: 'filePtr' : undeclared identifier
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(12) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(23) : error C2065: 'filePtr' : undeclared identifier
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(23) : warning C4047: 'function' : 'FILE *' differs in levels of indirection from 'int'
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(23) : warning C4024: 'fgetc' : different types for formal and actual parameter 1
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(29) : error C2065: 'filePtr' : undeclared identifier
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(29) : warning C4047: 'function' : 'FILE *' differs in levels of indirection from 'int'
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(29) : warning C4024: 'fclose' : different types for formal and actual parameter 1
1>Build log was saved at "file://c:\Documents and Settings\jon\My Documents\Visual Studio 2008\Projects\C_test\C_test\Debug\BuildLog.htm"
1>C_test - 6 error(s), 6 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any thoughts? Sorry if this is a>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(9) : error C2275: 'FILE' : illegal use of this type as an expression
1> c:\program files\microsoft visual studio 9.0\vc\include\stdio.h(69) : see declaration of 'FILE'
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(9) : error C2065: 'filePtr' : undeclared identifier
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(11) : error C2065: 'filePtr' : undeclared identifier
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(11) : warning C4047: '=' : 'int' differs in levels of indirection from 'FILE *'
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(12) : error C2065: 'filePtr' : undeclared identifier
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(12) : warning C4047: '==' : 'int' differs in levels of indirection from 'void *'
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(23) : error C2065: 'filePtr' : undeclared identifier
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(23) : warning C4047: 'function' : 'FILE *' differs in levels of indirection from 'int'
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(23) : warning C4024: 'fgetc' : different types for formal and actual parameter 1
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(29) : error C2065: 'filePtr' : undeclared identifier
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(29) : warning C4047: 'function' : 'FILE *' differs in levels of indirection from 'int'
1>c:\documents and settings\jon\my documents\visual studio 2008\projects\c_test\c_test\main.c(29) : warning C4024: 'fclose' : different types for formal and actual parameter 1
1>Build log was saved at "file://c:\Documents and Settings\jon\My Documents\Visual Studio 2008\Projects\C_test\C_test\Debug\BuildLog.htm"
1>C_test - 6 error(s), 6 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any thoughts? Thanks!
You can only declare variables at the top of a scope {} before any code in C.
In C++ you can declare them anywhere. So either change your filename to test.cpp or
move your first printf down below the declaration of FILE* fileptr.
int main(void )
{
FILE *filePtr;
printf("Hello");
BDB is compiled on the same PC, under same VS.
#include <db_cxx.h>
int main(){
Db b(NULL, 0);
return 0;
}
1>main.obj : error LNK2001: unresolved external symbol ""public: virtual __thiscall Db::~Db(void)" (??1Db##UAE#XZ)"
1>main.obj : error LNK2001: unresolved external symbol ""public: __thiscall Db::Db(class DbEnv *,unsigned int)" (??0Db##QAE#PAVDbEnv##I#Z)"
what could be wrong?
Did you remember to link in the binary created by compiling BDB?