Trying to view the _FILE_ID_BOTH_DIR_INFORMATION structure in memory with WinDbg - structure

I'm trying to view the Windows file system structure _FILE_ID_BOTH_DIR_INFORMATION in memory using WinDbg, but for some reason it tells me that the symbol is not found.
I connected WinDbg with a pipe to a Windows XP virtual machine in order to debug its kernel.
I tried viewing the structure's data using the command dt _FILE_ID_BOTH_DIR_INFORMATION esi because the value of ESI is an address which contains the structure in question that I want to inspect.
All I got was the following output:
3: kd> dt _FILE_ID_BOTH_DIR_INFORMATION esi
*************************************************************************
*** ***
*** ***
*** Either you specified an unqualified symbol, or your debugger ***
*** doesn't have full symbol information. Unqualified symbol ***
*** resolution is turned off by default. Please either specify a ***
*** fully qualified symbol module!symbolname, or enable resolution ***
*** of unqualified symbols by typing ".symopt- 100". Note that ***
*** enabling unqualified symbol resolution with network symbol ***
*** server shares in the symbol path may cause the debugger to ***
*** appear to hang for long periods of time when an incorrect ***
*** symbol name is typed or the network symbol server is down. ***
*** ***
*** For some commands to work properly, your symbol path ***
*** must point to .pdb files that have full type information. ***
*** ***
*** Certain .pdb files (such as the public OS symbols) do not ***
*** contain the required information. Contact the group that ***
*** provided you with these symbols if you need this command to ***
*** work. ***
*** ***
*** Type referenced: _FILE_ID_BOTH_DIR_INFORMATION ***
*** ***
*************************************************************************
Symbol _FILE_ID_BOTH_DIR_INFORMATION not found.
Other structures are working for me, like _DRIVER_OBJECT.
All I know about the _FILE_ID_BOTH_DIR_INFORMATION symbol is that it is included in ntifs.h, according to Microsoft's documentation. I couldn't find information regarding whether this symbol is provided from Microsoft Symbol Server.

no it appears this type info is not available in the public pdbs provided by ms
you can check yourself using wildcards
0: kd> dt nt!*_FILE_*
ntkrnlmp!_FILE_INFORMATION_CLASS
ntkrnlmp!_FILE_OBJECT
ntkrnlmp!_PF_FILE_ACCESS_TYPE
ntkrnlmp!_FILE_SEGMENT_ELEMENT
ntkrnlmp!_IOP_FILE_OBJECT_EXTENSION
ntkrnlmp!_CREATE_FILE_TYPE
ntkrnlmp!_FILE_OBJECT_EXTENSION_TYPE
ntkrnlmp!_DUMMY_FILE_OBJECT
ntkrnlmp!_IMAGE_FILE_HEADER
ntkrnlmp!_FILE_BASIC_INFORMATION
ntkrnlmp!_FILE_GET_QUOTA_INFORMATION
ntkrnlmp!_FILE_NETWORK_OPEN_INFORMATION
ntkrnlmp!_MMPAGE_FILE_EXPANSION
ntkrnlmp!_FILE_STANDARD_INFORMATION
ntkrnlmp!_MAPPED_FILE_SEGMENT
ntkrnlmp!_MMPAGE_FILE_EXPANSION_FLAGS
ntkrnlmp!_MI_PAGING_FILE_SPACE_BITMAPS
0: kd> dt nt!*_FILE_I*
ntkrnlmp!_FILE_INFORMATION_CLASS
as to view them you can view the Raw Contents of memory just do dd #esi
and corelate them with the Structure in ntifs.h
or use .printf and some find replace in notepad to print a formatted output
I just copy pasted the Structure From Documentation into notepad++
stuffed the .printf in front using find replace
stuffed the \t%x in the end using same procedure
tweaked the offsets to the PseudoRegister and saved it as .txt
used $$>a< to run it as windbg script providing a random offset to the Pseudo Register (just made sure there is some Unicode string at offset+0x48
the results are as below
r $t0 = (fffff805`19ec53e0-48)
.printf "typedef struct _FILE_ID_BOTH_DIR_INFORMATION { \n"
.printf " ULONG NextEntryOffset; \t%x\n" , #$t0+0
.printf " ULONG FileIndex; \t%x\n" , #$t0+4
.printf " LARGE_INTEGER CreationTime; \t%N\n" , #$t0+8
.printf " LARGE_INTEGER LastAccessTime; \t%N\n" , #$t0+10
.printf " LARGE_INTEGER LastWriteTime; \t%N\n" , #$t0+18
.printf " LARGE_INTEGER ChangeTime; \t%N\n" , #$t0+20
.printf " LARGE_INTEGER EndOfFile; \t%N\n" , #$t0+28
.printf " LARGE_INTEGER AllocationSize; \t%N\n" , #$t0+30
.printf " ULONG FileAttributes; \t%x\n" , #$t0+38
.printf " ULONG FileNameLength; \t%x\n" , #$t0+3c
.printf " ULONG EaSize; \t%x\n" , #$t0+40
.printf " CCHAR ShortNameLength; \t%x\n" , #$t0+44
.printf " WCHAR ShortName[12]; \t%mu\n" , #$t0+48
.printf " LARGE_INTEGER FileId; \t%N\n" , #$t0+54
.printf " WCHAR FileName[1]; \t%mu\n" , #$t0+58
.printf "} FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION; \n"
results
0: kd> $$>a< f:\wdscr\fileid.wds
typedef struct _FILE_ID_BOTH_DIR_INFORMATION {
ULONG NextEntryOffset; 19ec5398
ULONG FileIndex; 19ec539c
LARGE_INTEGER CreationTime; FFFFF80519EC53A0
LARGE_INTEGER LastAccessTime; FFFFF80519EC53A8
LARGE_INTEGER LastWriteTime; FFFFF80519EC53B0
LARGE_INTEGER ChangeTime; FFFFF80519EC53B8
LARGE_INTEGER EndOfFile; FFFFF80519EC53C0
LARGE_INTEGER AllocationSize; FFFFF80519EC53C8
ULONG FileAttributes; 19ec53d0
ULONG FileNameLength; 19ec53d4
ULONG EaSize; 19ec53d8
CCHAR ShortNameLength; 19ec53dc
WCHAR ShortName[12]; KeRevertToUserGroupAffinityThread
LARGE_INTEGER FileId; FFFFF80519EC53EC
WCHAR FileName[1]; ToUserGroupAffinityThread
} FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION;

Related

Build aruco 2.0.5 on Windows 8

I am trying to install aruco on my Windows machine using cmake 3.5.2 as suggested by the aruco developper.
My config:
Windows8
CMake 3.5.2
ArUco 2.0.5
I can configure and generate successfully aruco in cmake.
Then I go to aruco\build -> right click-> open cmd -> type mingw32-make -> get the following error:
C:\aruco-2.0.5\build>mingw32-make
Scanning dependencies of target aruco
[ 2%] Building CXX object src/CMakeFiles/aruco.dir/ar_omp.cpp.obj
[ 4%] Building CXX object src/CMakeFiles/aruco.dir/cameraparameters.cpp.obj
[ 6%] Building CXX object src/CMakeFiles/aruco.dir/cvdrawingutils.cpp.obj
In file included from C:\aruco-2.0.5\src\aruco.h:149:0,
from C:\aruco-2.0.5\src\cvdrawingutils.h:31,
from C:\aruco-2.0.5\src\cvdrawingutils.cpp:28:
C:\aruco-2.0.5\src\markerdetector.h:160:40: warning: "/*" within comment [-Wcomm
ent]
ARUCO_MIP_36h12, //**** recommended
^
C:\aruco-2.0.5\src\markerdetector.h:212:60: warning: unused parameter 'r2' [-Wun
used-parameter]
void setThresholdParamRange(size_t r1 = 0, size_t r2 = 0) {_params. _thresP
aram1_range = r1; }
^
C:\aruco-2.0.5\src\markerdetector.h:267:30: warning: unused parameter 'val' [-Wu
nused-parameter]
void setDesiredSpeed(int val){}
^
In file included from C:\aruco-2.0.5\src\posetracker.h:33:0,
from C:\aruco-2.0.5\src\aruco.h:150,
from C:\aruco-2.0.5\src\cvdrawingutils.h:31,
from C:\aruco-2.0.5\src\cvdrawingutils.cpp:28:
C:\aruco-2.0.5\src\markermap.h: In member function 'void aruco::Marker3DInfo::to
Stream(std::ostream&)':
C:\aruco-2.0.5\src\markermap.h:49:77: warning: comparison between signed and uns
igned integer expressions [-Wsign-compare]
void toStream(std::ostream &str){str<<id<<" "<<size()<<" ";for(int i=0;i<si
ze();i++) str<<at(i).x<<" "<<at(i).y<<" "<<at(i).z<<" ";}
^
In file included from C:\aruco-2.0.5\src\posetracker.h:33:0,
from C:\aruco-2.0.5\src\aruco.h:150,
from C:\aruco-2.0.5\src\cvdrawingutils.h:31,
from C:\aruco-2.0.5\src\cvdrawingutils.cpp:28:
C:\aruco-2.0.5\src\markermap.h: In member function 'void aruco::Marker3DInfo::fr
omStream(std::istream&)':
C:\aruco-2.0.5\src\markermap.h:50:80: warning: comparison between signed and uns
igned integer expressions [-Wsign-compare]
void fromStream(std::istream &str){int s;str>>id>>s;resize(s);for(int i=0;i
<size();i++) str>>at(i).x>>at(i).y>>at(i).z;}
^
[ 9%] Building CXX object src/CMakeFiles/aruco.dir/dictionary.cpp.obj
In file included from C:\aruco-2.0.5\src\dictionary.cpp:9:0:
C:\aruco-2.0.5\src\markermap.h: In member function 'void aruco::Marker3DInfo::to
Stream(std::ostream&)':
C:\aruco-2.0.5\src\markermap.h:49:77: warning: comparison between signed and uns
igned integer expressions [-Wsign-compare]
void toStream(std::ostream &str){str<<id<<" "<<size()<<" ";for(int i=0;i<si
ze();i++) str<<at(i).x<<" "<<at(i).y<<" "<<at(i).z<<" ";}
^
In file included from C:\aruco-2.0.5\src\dictionary.cpp:9:0:
C:\aruco-2.0.5\src\markermap.h: In member function 'void aruco::Marker3DInfo::fr
omStream(std::istream&)':
C:\aruco-2.0.5\src\markermap.h:50:80: warning: comparison between signed and uns
igned integer expressions [-Wsign-compare]
void fromStream(std::istream &str){int s;str>>id>>s;resize(s);for(int i=0;i
<size();i++) str>>at(i).x>>at(i).y>>at(i).z;}
^
C:\aruco-2.0.5\src\dictionary.cpp: In static member function 'static std::string
aruco::Dictionary::getTypeString(aruco::Dictionary::DICT_TYPES)':
C:\aruco-2.0.5\src\dictionary.cpp:236:11: warning: enumeration value 'ARTAG' not
handled in switch [-Wswitch]
switch(t){
^
C:\aruco-2.0.5\src\dictionary.cpp: In member function 'aruco::MarkerMap aruco::D
ictionary::createMarkerMap(cv::Size, int, int, const std::vector<int>&, bool)':
C:\aruco-2.0.5\src\dictionary.cpp:275:39: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]
if (gridSize.height*gridSize.width!=ids.size())throw cv::Exception(9001, "g
ridSize != ids.size()Invalid ", "Dictionary::createMarkerMap", __FILE__, __LINE_
_);
^
C:\aruco-2.0.5\src\dictionary.cpp:284:23: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]
for (int i=0;i<ids.size();i++) TInfo[i].id=ids[i];
^
C:\aruco-2.0.5\src\dictionary.cpp:285:13: warning: unused variable 'sizeY' [-Wun
used-variable]
int sizeY=gridSize.height*MarkerSize+(gridSize.height-1)*MarkerDistance
;
^
C:\aruco-2.0.5\src\dictionary.cpp:286:13: warning: unused variable 'sizeX' [-Wun
used-variable]
int sizeX=gridSize.width*MarkerSize+(gridSize.width-1)*MarkerDistance;
^
C:\aruco-2.0.5\src\dictionary.cpp:312:37: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]
if (CurMarkerIdx>=ids.size()) throw cv::Exception(999," Fid
ucidalMarkers::createMarkerMapImage_ChessMarkerMap","INTERNAL ERROR. REWRITE THI
S!!",__FILE__,__LINE__);
^
C:\aruco-2.0.5\src\dictionary.cpp:300:13: warning: unused variable 'centerX' [-W
unused-variable]
int centerX=sizeX/2;
^
C:\aruco-2.0.5\src\dictionary.cpp:301:13: warning: unused variable 'centerY' [-W
unused-variable]
int centerY=sizeY/2;
^
C:\aruco-2.0.5\src\dictionary.cpp:303:14: warning: unused variable 'centerData'
[-Wunused-variable]
bool centerData=true;
^
[ 11%] Building CXX object src/CMakeFiles/aruco.dir/ippe.cpp.obj
C:\aruco-2.0.5\src\ippe.cpp: In function 'void IPPE::IPPComputeRotations(double,
double, double, double, double, double, cv::OutputArray, cv::OutputArray)':
C:\aruco-2.0.5\src\ippe.cpp:307:45: warning: variable 'ata10' set but not used [
-Wunused-but-set-variable]
double a00, a01, a10,a11, ata00, ata01, ata10,ata11,b00, b01, b10,b11,binv0
0, binv01, binv10,binv11;
^
C:\aruco-2.0.5\src\ippe.cpp:311:19: warning: variable 'a' set but not used [-Wun
used-but-set-variable]
double b0, b1,a,gamma,dtinv;
^
[ 13%] Building CXX object src/CMakeFiles/aruco.dir/marker.cpp.obj
C:\aruco-2.0.5\src\marker.cpp: In member function 'void aruco::Marker::rotateXAx
is(cv::Mat&)':
C:\aruco-2.0.5\src\marker.cpp:299:22: error: 'M_PI' was not declared in this sco
pe
float angleRad = M_PI / 2;
^
src\CMakeFiles\aruco.dir\build.make:187: recipe for target 'src/CMakeFiles/aruco
.dir/marker.cpp.obj' failed
mingw32-make[2]: *** [src/CMakeFiles/aruco.dir/marker.cpp.obj] Error 1
CMakeFiles\Makefile2:116: recipe for target 'src/CMakeFiles/aruco.dir/all' faile
d
mingw32-make[1]: *** [src/CMakeFiles/aruco.dir/all] Error 2
Makefile:126: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
C:\aruco-2.0.5\build>mingw32-make
Scanning dependencies of target aruco
[ 2%] Building CXX object src/CMakeFiles/aruco.dir/marker.cpp.obj
C:\aruco-2.0.5\src\marker.cpp: In member function 'void aruco::Marker::rotateXAx
is(cv::Mat&)':
C:\aruco-2.0.5\src\marker.cpp:299:22: error: 'M_PI' was not declared in this sco
pe
float angleRad = M_PI / 2;
^
src\CMakeFiles\aruco.dir\build.make:187: recipe for target 'src/CMakeFiles/aruco
.dir/marker.cpp.obj' failed
mingw32-make[2]: *** [src/CMakeFiles/aruco.dir/marker.cpp.obj] Error 1
CMakeFiles\Makefile2:116: recipe for target 'src/CMakeFiles/aruco.dir/all' faile
d
mingw32-make[1]: *** [src/CMakeFiles/aruco.dir/all] Error 2
Makefile:126: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
I have also tried to do it with codeblocks but I get the exact same error.
The developer has released a new version 2.0.7 fixing this issue.
What I have done to have aruco:
download the .zip on sourceforge
unzip it
create a build folder in aruco-2.0.7
open cmake-gui configure and generate
go into your build folder
open a cmd window from there
type mingw32-make
The library should have compiled properly.
If omp.h is missing from your compiler, find the source code on the internet and add it to mingw in MinGW\include. You should be ready to go. Don't forget to add aruco to your path & reboot.
If you are using an ide, you will have to add this library since it is an external library but it is another issue.
Finally, you might have some issues regarding c++11. I am working on it. If someone knows how to allow it on mingw (I haven't find any understandable explanation so far)

How to build dash with CMake?

I'm trying to build dash using Clion and CMake but I get this build error:
/opt/clion-2016.1.1/bin/cmake/bin/cmake --build /home/dac/.CLion2016.1/system/cmake/generated/dash-46b33cad/46b33cad/Debug --target all -- -j 4
[ 3%] Building C object CMakeFiles/main.dir/error.c.o
[ 6%] Building C object CMakeFiles/main.dir/eval.c.o
[ 9%] Building C object CMakeFiles/main.dir/cd.c.o
[ 12%] Building C object CMakeFiles/main.dir/arith_yylex.c.o
In file included from /home/dac/Downloads/dash-0.5.8/dash/error.c:54:0:
/home/dac/Downloads/dash-0.5.8/dash/system.h:65:22: error: static declaration of ‘strtod’ follows non-static declaration
static inline double strtod(const char *nptr, char **endptr)
^
In file included from /home/dac/Downloads/dash-0.5.8/dash/error.c:40:0:
/usr/include/stdlib.h:164:15: note: previous declaration of ‘strtod’ was here
extern double strtod (const char *__restrict __nptr,
^
In file included from /home/dac/Downloads/dash-0.5.8/dash/error.c:54:0:
/home/dac/Downloads/dash-0.5.8/dash/system.h:86:19: error: static declaration of ‘killpg’ follows non-static declaration
static inline int killpg(pid_t pid, int signal)
^
In file included from /home/dac/Downloads/dash-0.5.8/dash/error.c:39:0:
/usr/include/signal.h:134:12: note: previous declaration of ‘killpg’ was here
extern int killpg (__pid_t __pgrp, int __sig) __THROW;
^
In file included from /home/dac/Downloads/dash-0.5.8/dash/error.c:54:0:
/home/dac/Downloads/dash-0.5.8/dash/system.h:97:0: warning: "_SC_CLK_TCK" redefined
#define _SC_CLK_TCK 2
^
In file included from /usr/include/unistd.h:609:0,
from /home/dac/Downloads/dash-0.5.8/dash/error.c:42:
/usr/include/x86_64-linux-gnu/bits/confname.h:78:0: note: this is the location of the previous definition
#define _SC_CLK_TCK _SC_CLK_TCK
^
CMakeFiles/main.dir/build.make:182: recipe for target 'CMakeFiles/main.dir/error.c.o' failed
make[2]: *** [CMakeFiles/main.dir/error.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/home/dac/Downloads/dash-0.5.8/dash/eval.c:51:22: fatal error: builtins.h: No such file or directory
In file included from /home/dac/Downloads/dash-0.5.8/dash/arith_yylex.c:44:0:
/home/dac/Downloads/dash-0.5.8/dash/system.h:65:22: error: static declaration of ‘strtod’ follows non-static declaration
static inline double strtod(const char *nptr, char **endptr)
^
In file included from /home/dac/Downloads/dash-0.5.8/dash/arith_yylex.c:36:0:
/usr/include/stdlib.h:164:15: note: previous declaration of ‘strtod’ was here
extern double strtod (const char *__restrict __nptr,
^
In file included from /home/dac/Downloads/dash-0.5.8/dash/arith_yylex.c:44:0:
/home/dac/Downloads/dash-0.5.8/dash/system.h:86:19: error: static declaration of ‘killpg’ follows non-static declaration
static inline int killpg(pid_t pid, int signal)
^
In file included from /home/dac/Downloads/dash-0.5.8/dash/error.h:38:0,
from /home/dac/Downloads/dash-0.5.8/dash/arith_yylex.c:40:
/usr/include/signal.h:134:12: note: previous declaration of ‘killpg’ was here
extern int killpg (__pid_t __pgrp, int __sig) __THROW;
^
In file included from /home/dac/Downloads/dash-0.5.8/dash/syntax.h:5:0,
from /home/dac/Downloads/dash-0.5.8/dash/arith_yylex.c:43:
/home/dac/Downloads/dash-0.5.8/dash/system.h:102:17: error: expected ‘)’ before ‘c’
int isblank(int c);
^
/home/dac/Downloads/dash-0.5.8/dash/system.h:102:5: error: expected expression before ‘)’ token
int isblank(int c);
^
compilation terminated.
CMakeFiles/main.dir/build.make:206: recipe for target 'CMakeFiles/main.dir/eval.c.o' failed
make[2]: *** [CMakeFiles/main.dir/eval.c.o] Error 1
CMakeFiles/main.dir/build.make:134: recipe for target 'CMakeFiles/main.dir/arith_yylex.c.o' failed
make[2]: *** [CMakeFiles/main.dir/arith_yylex.c.o] Error 1
My CMakeLists.txt looks like this:
cmake_minimum_required (VERSION 2.6)
project (dash)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include config.h -DBSD=1 -DSHELL -DIFS_BROKEN")
add_executable(main main.c alias.c arith_yacc.c arith_yylex.c cd.c error.c eval.c exec.c expand.c histedit.c input.c jobs.c mail.c main.c memalloc.c miscbltin.c mystring.c options.c parser.c redir.c show.c trap.c output.c bltin/printf.c system.c bltin/test.c bltin/times.c var.c alias.h arith_yacc.h bltin/bltin.h cd.h error.h eval.h exec.h expand.h hetio.h init.h input.h jobs.h machdep.h mail.h main.h memalloc.h miscbltin.h myhistedit.h mystring.h options.h output.h parser.h redir.h shell.h show.h system.h trap.h var.h mktokens mkbuiltins builtins.def.in mkinit.c mknodes.c nodetypes nodes.c.pat mksyntax.c mksignames.c)
What can I do to make it build? If I use the makefile and build with make then it builds. But I want to build with CMake.

Calling Fortran from C++-CLI

I have a fortran subroutine, FortranShake, and a C++ main function, HandShakingTest.cpp.
I'm trying to call a fortran subroutine from CLR C++.
I'm getting two batches of errors. Let's call them ERROR(1) and ERROR(2). I'd really appreciate if you could help me understand why these errors are happening.
When I try to compile with the following:
cl /clr HandShakingTest.cpp
I get the following ERROR(1):
HandShakingTest.obj : error LNK2028: unresolved token (0A00030A) "extern "C" void __c
ecl FortranShake(int &)" (?FortranShake##$$J0YAXAAH#Z) referenced in function "int __
lrcall main(cli::array<class System::String ^ >^)" (?main##$$HYMHP$01AP$AAVString#Sys
em###Z)
HandShakingTest.obj : error LNK2019: unresolved external symbol "extern "C" void __cd
cl FortranShake(int &)" (?FortranShake##$$J0YAXAAH#Z) referenced in function "int __c
rcall main(cli::array<class System::String ^ >^)" (?main##$$HYMHP$01AP$AAVString#Syst
m###Z)
HandShakingTest.exe : fatal error LNK1120: 2 unresolved externals
I then used the following commands to compile instead:
ifort /c FortranShake.f //Which compiles fine
cl /c /clr HandShakingTest.cpp //compiles fine
cl /o test HandShakingTest.obj FortranShake.obj //ERROR(2) occurs
ERROR(2) consists of:
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(cla
ss type_info const &)" (??0type_info##AAE#ABV0##Z) already defined in LIBCMT.lib(typin
fo.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_i
nfo::operator=(class type_info const &)" (??4type_info##AAEAAV0#ABV0##Z) already defin
ed in LIBCMT.lib(typinfo.obj)
MSVCRT.lib(merr.obj) : error LNK2005: __matherr already defined in LIBCMT.lib(_matherr
_.obj)
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NOD
EFAULTLIB:library
HandShakingTest.obj : error LNK2028: unresolved token (0A00030A) "extern "C" void __cd
ecl FortranShake(int &)" (?FortranShake##$$J0YAXAAH#Z) referenced in function "int __c
lrcall main(cli::array<class System::String ^ >^)" (?main##$$HYMHP$01AP$AAVString#Syst
em###Z)
HandShakingTest.obj : error LNK2019: unresolved external symbol "extern "C" void __cde
cl FortranShake(int &)" (?FortranShake##$$J0YAXAAH#Z) referenced in function "int __cl
rcall main(cli::array<class System::String ^ >^)" (?main##$$HYMHP$01AP$AAVString#Syste
m###Z)
libifcoremt.lib(for_main.obj) : error LNK2019: unresolved external symbol _MAIN__ refe
renced in function _main
test.exe : fatal error LNK1120: 3 unresolved externals
Here's the HandShakingTest.cpp:
#include "stdio.h"
#include <stdlib.h>
#include <Windows.h>
#using <System.DLL>
#using <System.Windows.Forms.DLL>
using namespace std;
using namespace System;
using namespace System::IO;
using namespace System::Diagnostics;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
extern "C" {void FortranShake(int&);}
int main(array<System::String ^> ^args)
{
Process^ testHand = gcnew Process();
testHand->StartInfo->UseShellExecute = false;
testHand->StartInfo->RedirectStandardInput = true;
testHand->StartInfo->RedirectStandardOutput = true;
testHand->StartInfo->ErrorDialog = true;
int numDebug = 0;
String^ returnedDebug = "Nothing";
FortranShake(numDebug);
StreamReader^ FromHandProcess = testHand->StandardOutput;
StreamWriter^ ToHandProcess = testHand->StandardInput;
String^ Line;
Line = FromHandProcess ->ReadLine();
if (Line->Equals("Enter Hand") )
{
Console::WriteLine(L"Hand Started!");
}
ToHandProcess ->WriteLine(numDebug.ToString());
returnedDebug = FromHandProcess ->ReadLine();
MessageBox::Show(returnedDebug);
return 0;
}
Here is the Fortran Subroutine:
SUBROUTINE FortranShake(GP_DEBUG)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
INN = 5
WRITE(06,'(a)') 'Enter Hand'
READ(INN,*) GP_DEBUG
GP_DEBUG = GP_DEBUG + 55
WRITE(06,*) GP_DEBUG
RETURN
END
Your first error is actually a linker error - without the /c command line switch you are compiling and linking in one step. No Fortran code or object code has been provided.
Your second error is because:
You have specified (through omission) mismatching runtime libraries for the C++ and the Fortran. You need to decide whether you want to use static linking (the default for the current (as of today, but not necessarily as of next month...) release of Intel Fortran on windows) or dynamic linking (the default for the MS C++ compiler). Perhaps add /MD to the ifort command line, which specifies dynamic linking.
Without compiler options or directives to the contrary, the equivalent identifier for the Fortran procedure in C code as generated by that Fortran compiler is an upper case variant of the Fortran procedure's name - i.e. in the C++ code call the procedure FORTRANSHAKE. If you can write your Fortran code to the F2003 standard, you should use the C interoperability features of that language (BIND(C,...)) to control the C binding name of the Fortran procedure and ensure calling conventions, etc align.
The dummy argument of the Fortran subroutine has the DOUBLE PRECISION type specifier, which is equivalent to double in the C++ for this combination of compilers, not int. Again, F2003 introduces features that can make this alignment of argument types more robust.

MessageBoxW cannot convert

I am using wxWidgets 2.9.4 in Visual Studio 2012 and I keep getting these two error messages:
Error 1 error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char *' to 'LPCWSTR'
IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR"
My code is:
#ifdef _WIN32
std::string msg;
StringFromFormatV(&msg, format, args);
retval = IDYES == MessageBox(0, msg.c_str(), "ERROR! Continue?", MB_ICONQUESTION | MB_YESNO);
You are compiling your project using multi-byte characters as default. You can change that in your project's properties, or you can use msg.wc_str(), or even enforce the use of MessageBoxA instead of using the macro MessageBox.

Trouble with libgsl and wxwidget

I'm having difficulty building a project in Windows 7 / Visual Studio 2010, and already spent longer than I would admit googling and fixing other errors to get to this point, but frustratingly I can't seem to get rid of the very last error. There is a linker error related to the _hypot function defined in math.h:
wxTheAppInitializer" (?wxTheAppInitializer##3VwxAppInitializer##A)
already defined in main.obj 1>libgsl.a(linalg_svd.o) : error LNK2019:
unresolved external symbol _hypot referenced in function
_gsl_linalg_SV_decomp 1>libgsl.a(matrix_oper.o) : error LNK2001: unresolved external symbol _hypot 1>libgsl.a(linalg_householder.o) :
error LNK2001: unresolved external symbol _hypot
: fatal error LNK1120: 1 unresolved externals
When I follow the advice of unresolved external symbol "_hypot" when using static library I get the following:
1> Generating Code... 1> main.obj : error LNK2005: _hypot already
defined in About.obj 1> fatal error LNK1169: one or more multiply
defined symbols found
Could anyone explain what is going on?
Create .c file with the following contents:
extern double fabs(double);
extern double sqrt(double);
double hypot(double x, double y) {
double ax = fabs(x), ay = fabs(y);
double xy = x/y, yx = y/x;
return ax > ay
? ax * sqrt(1.0 + yx*yx)
: ay * sqrt(1.0 + xy*xy);
}
do not include math.h