Discussions related to Visual Prolog
alex63
Posts: 3
Joined: 11 Mar 2012 10:17

Call C++ in VIP7.5

Unread post by alex63 »

Hi.
Calling function malloc in C
in example
http://discuss.visual-prolog.com/viewto ... indtoc+zip
doesn't work in in VIP 7.5
Help and explain why
========================================
Dump: 2015-01-14 19:29:36
----------------------------------------
Exception: systemException (runtime_exception)

System exception

error code = 1
ExtraInfo = Exception C0000005: Access violation

raised 2015-01-14 19:29:34
ThreadId: 3956
Class name: runtime_exception
Predicate name: runtimeExceptionRaiser


G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\VProlog_project.exe (0x005220D7)
G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\vipKernel.dll (0x14008516)
G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\vipKernel.dll (0x14006189)
C:\Windows\SysWOW64\ntdll.dll (0x77CB6AB9)
C:\Windows\SysWOW64\ntdll.dll (0x77CB6A8B)
C:\Windows\SysWOW64\ntdll.dll (0x77C80143)
clink_tutorial\mylib.pro(139)
taskwindow\taskwindow.pro(84)
c:\program files (x86)\visual prolog 7.5\pfc\gui\window.pro(863)
c:\program files (x86)\visual prolog 7.5\pfc\gui\window.pro(1976)
c:\program files (x86)\visual prolog 7.5\pfc\gui\documentwindow.pro(279)
G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\vipKernel.dll (0x14008735)
G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\vipVpi.dll (0x15310C28)
G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\vipVpi.dll (0x15315D57)
G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\vipVpi.dll (0x153139B1)
G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\vipVpi.dll (0x1531B9D5)
C:\Windows\syswow64\USER32.dll (0x776862FA)
C:\Windows\syswow64\USER32.dll (0x77686D3A)
C:\Windows\syswow64\USER32.dll (0x77686DE8)
C:\Windows\syswow64\USER32.dll (0x7768A740)
C:\Windows\SysWOW64\ntdll.dll (0x77C8011A)
C:\Windows\syswow64\USER32.dll (0x7768AA3C)
C:\Windows\syswow64\USER32.dll (0x77688A5C)
G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\vipVpi.dll (0x1531A3DB)
c:\program files (x86)\visual prolog 7.5\pfc\vpi\vpi.pro(21)
c:\program files (x86)\visual prolog 7.5\pfc\windowsapi\exe_api\exe_api.pro(63)
c:\program files (x86)\visual prolog 7.5\pfc\application\exe\mainexe.pro(21)
main.pro(23)
G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\vipKernel.dll (0x1400884B)
G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\vipKernel.dll (0x14008B0B)
G:\Visual Prolog Projects\call_VIP_in_C++\BindToC_inVip7-5\VP_project\VProlog_project\Exe\VProlog_project.exe (0x005222A7)
C:\Windows\SysWOW64\ntdll.dll (0x77CA9ED2)
C:\Windows\SysWOW64\ntdll.dll (0x77CA9EA5)

----------------------------------------
OS information:

Microsoft Windows 7 Windows 7 Ultimate Service Pack 1 64-bit (Build 7601)
Number Of Processors: 4 PageSize: 4096 Processor: 8664 level: 6 revision: 7685
ProcessorNameString: Intel(R) Core(TM) i5 CPU 750 @ 2.67GHz
VendorIdentifier: GenuineIntel
Identifier: Intel64 Family 6 Model 30 Stepping 5
~MHz: 2664
User avatar
Thomas Linder Puls
VIP Member
Posts: 1194
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

The article "Binding to C" is unfortunately rather outdated and have (now) been deleted.

When binding to foreign code (e.g. C/C++) the foreign code should be in a DLL. Otherwise you will have lots of linking problems. Further more the foreign code should not attempt to create Visual Prolog data, it should create ordinary foreign data, which your Visual Prolog program should "translate" to Visual Prolog format.

See the (remaining) Memory Handling tutorials.
Regards Thomas Linder Puls
PDC
Post Reply