<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[QUIK -> DDE &mdash; Проблема с DLL собранной в c++ Builder]]></title>
	<link rel="self" href="https://quik2dde.ru/extern.php?action=feed&amp;tid=155&amp;type=atom" />
	<updated>2015-05-03T12:54:52Z</updated>
	<generator>PunBB</generator>
	<id>https://quik2dde.ru/viewtopic.php?id=155</id>
		<entry>
			<title type="html"><![CDATA[Re: Проблема с DLL собранной в c++ Builder]]></title>
			<link rel="alternate" href="https://quik2dde.ru/viewtopic.php?pid=1317#p1317" />
			<content type="html"><![CDATA[<p>Искал так и сяк в интернете - похоже нет для C++ builder варианта отключить декорирование без DEF-файла. Грустно это.</p>]]></content>
			<author>
				<name><![CDATA[swerg]]></name>
				<uri>https://quik2dde.ru/profile.php?id=78</uri>
			</author>
			<updated>2015-05-03T12:54:52Z</updated>
			<id>https://quik2dde.ru/viewtopic.php?pid=1317#p1317</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблема с DLL собранной в c++ Builder]]></title>
			<link rel="alternate" href="https://quik2dde.ru/viewtopic.php?pid=1316#p1316" />
			<content type="html"><![CDATA[<p>)ЗАРАБОТАЛО))))))))) Помогла статья ( создание алиасов в def файле!)...&nbsp; И еще хотел бы спросить совет.... У меня есть задача пересадить своего робота полностью на луа.....избавиться от quik api и DDe... из статей понял что это можно сделать через сокеты......С сокетами к сожалению не работал....и не совсем понимаю какие объемы&nbsp; языка луа мне необходимо изучить....чтобы мое приложение на с++ общалось с квиком через длл...в сторону чего вообще копать !!!</p>]]></content>
			<author>
				<name><![CDATA[Kirill.V]]></name>
				<uri>https://quik2dde.ru/profile.php?id=267</uri>
			</author>
			<updated>2015-05-03T12:31:16Z</updated>
			<id>https://quik2dde.ru/viewtopic.php?pid=1316#p1316</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблема с DLL собранной в c++ Builder]]></title>
			<link rel="alternate" href="https://quik2dde.ru/viewtopic.php?pid=1315#p1315" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>swerg пишет:</cite><blockquote><p>Кстати, вы ведь не забыли добавить в проект определение директив препроцессора LUA_LIB и LUA_BUILD_AS_DLL ?</p></blockquote></div><p>Нет не забыл я ее прописал так<br /></p><div class="codebox"><pre><code>#define LUA_LIB
#define LUA_BUILD_AS_DLL</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Kirill.V]]></name>
				<uri>https://quik2dde.ru/profile.php?id=267</uri>
			</author>
			<updated>2015-05-03T12:01:36Z</updated>
			<id>https://quik2dde.ru/viewtopic.php?pid=1315#p1315</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблема с DLL собранной в c++ Builder]]></title>
			<link rel="alternate" href="https://quik2dde.ru/viewtopic.php?pid=1314#p1314" />
			<content type="html"><![CDATA[<p>RAD studio XE 7</p>]]></content>
			<author>
				<name><![CDATA[Kirill.V]]></name>
				<uri>https://quik2dde.ru/profile.php?id=267</uri>
			</author>
			<updated>2015-05-03T11:59:26Z</updated>
			<id>https://quik2dde.ru/viewtopic.php?pid=1314#p1314</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблема с DLL собранной в c++ Builder]]></title>
			<link rel="alternate" href="https://quik2dde.ru/viewtopic.php?pid=1313#p1313" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>ошибка error loading module &#039;luacdll&#039; from file &#039;.\luacdll.dll&#039;:<br />&nbsp; &nbsp; Не найдена указанная процедура.</p></blockquote></div><p>А вот теперь бы самое время посмотреть что экспортируется из DLL.<br />Судя по ошибке, не экспортируется или экспортируется с &quot;неожиданным&quot; именем функция luaopen_luacdll</p><p>Вот [url=http://rsdn.ru/article/devtools/bcbdll.xml]статья про предыскажение имен функций в компиляторах С++[/url], правда дата у нее не очень свежая.<br />Из написанного там пока понятно лишь, что надо добавить в проект def-файл с именами экспортируемых функций, который (на сколько я могу судить о этой статье) для BCB работает.</p><p>Возможно, в вашей версии С++ Builder уже есть подходящая директива компилятора, чтобы имена не предыскажались, но её надо еще сыскать.</p><p>Вы каким именно (в смысле версии) компилятором пользуетесь?</p><p>Кстати, вы ведь не забыли добавить в проект определение директив препроцессора LUA_LIB и LUA_BUILD_AS_DLL ?</p>]]></content>
			<author>
				<name><![CDATA[swerg]]></name>
				<uri>https://quik2dde.ru/profile.php?id=78</uri>
			</author>
			<updated>2015-05-03T11:19:48Z</updated>
			<id>https://quik2dde.ru/viewtopic.php?pid=1313#p1313</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблема с DLL собранной в c++ Builder]]></title>
			<link rel="alternate" href="https://quik2dde.ru/viewtopic.php?pid=1312#p1312" />
			<content type="html"><![CDATA[<p>Сделал все по примеру...Приложу на всякий случай код<br /></p><div class="codebox"><pre><code>#pragma hdrstop
#pragma argsused
#define LUA_LIB
#define LUA_BUILD_AS_DLL
#include &lt;stdio.h&gt;
#include &lt;windows.h&gt;
#include &lt;process.h&gt;
extern &quot;C&quot; {
#include &lt;lauxlib.h&gt;
#include &lt;lualib.h&gt;
#include &lt;lua.h&gt;
}


int _libmain(unsigned long reason)
{
    return 1;
}



// реализация функций, вызываемых из LUA

static int forLua_GetCurrentThreadId(lua_State *L) {
    // возвращаем одно значение, полученное от Win API функции
    lua_pushinteger(L, GetCurrentThreadId());
    return(1);
}

static int forLua_MultTwoNumbers(lua_State *L) {
    // получаем первый и второй параметры вызова функции из стека с проверкой каждого на число
    double d1 = luaL_checknumber(L, 1);
    double d2 = luaL_checknumber(L, 2);

    // помещаем в стек результат умножения
    lua_pushnumber(L, d1 * d2);

    return(1);  // эта функция возвращает одно значение
}

static int forLua_MultAllNumbers(lua_State *L) {
    const int n = lua_gettop(L);  // количество переданных аргументов
    double res = 1;
    bool isNumberFound = false;
    for (int i = 1; i &lt;= n; ++i)
        if (lua_type(L, i) == LUA_TNUMBER)
        {
            res *= lua_tonumber(L, i);
            isNumberFound = true;
        }

    if (isNumberFound)
        lua_pushnumber(L, res);
    else
        lua_pushnil(L);

    return(1);
}

// регистрация реализованных в dll функций, чтобы они стали &quot;видимы&quot; для LUA

static struct luaL_reg ls_lib[] = {
    {&quot;GetCurrentThreadId&quot;, forLua_GetCurrentThreadId},
    {&quot;MultTwoNumbers&quot;, forLua_MultTwoNumbers},
    {&quot;MultAllNumbers&quot;, forLua_MultAllNumbers},
    {NULL, NULL}
};

extern &quot;C&quot;
 LUALIB_API int luaopen_luacdll(lua_State *L) {
    luaL_openlib(L, &quot;luacdll&quot;, ls_lib, 0);
    return 0;
}</code></pre></div><p>Скрипт полностью из примера....<br />Теперь в квике:<br /> ошибка error loading module &#039;luacdll&#039; from file &#039;.\luacdll.dll&#039;:<br />&nbsp; &nbsp; Не найдена указанная процедура.</p>]]></content>
			<author>
				<name><![CDATA[Kirill.V]]></name>
				<uri>https://quik2dde.ru/profile.php?id=267</uri>
			</author>
			<updated>2015-05-03T10:57:30Z</updated>
			<id>https://quik2dde.ru/viewtopic.php?pid=1312#p1312</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Проблема с DLL собранной в c++ Builder]]></title>
			<link rel="alternate" href="https://quik2dde.ru/viewtopic.php?pid=1311#p1311" />
			<content type="html"><![CDATA[<p>Например в том, что перед <strong>luaopen_MyFun</strong> есть <strong>_stdcall</strong>, которое не нужно, т.к. в Lua-dll используется <strong>cdecl</strong> соглашение о вызовах (которое в С++ по умолчанию).<br />Возьмите готовый пример за основу, не делайте совсем с нуля. Я ж его специально выложил, чтобы были готовые для копирования куски.</p><p>В любом случае спасибо за подробный, но при этом маленький по объёму пример проблемы. Это идеальный вариант задавания вопросов на форумах.</p>]]></content>
			<author>
				<name><![CDATA[swerg]]></name>
				<uri>https://quik2dde.ru/profile.php?id=78</uri>
			</author>
			<updated>2015-05-03T10:34:35Z</updated>
			<id>https://quik2dde.ru/viewtopic.php?pid=1311#p1311</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Проблема с DLL собранной в c++ Builder]]></title>
			<link rel="alternate" href="https://quik2dde.ru/viewtopic.php?pid=1310#p1310" />
			<content type="html"><![CDATA[<p>Доброго дня суток!!! По примерам с сайта создал свою длл...вот ее код<br /></p><div class="codebox"><pre><code>#pragma hdrstop
#pragma argsused
#define LUA_LIB
#define LUA_BUILD_AS_DLL
#include &lt;stdio.h&gt;

extern &quot;C&quot; {
#include &lt;lauxlib.h&gt;
#include &lt;lualib.h&gt;
#include &lt;lua.h&gt;
}


int _libmain(unsigned long reason)
{
    return 1;
}


 static int forLua_TestFunc(lua_State *L)// Возвращает заданный текст
{
    lua_pushstring(L, &quot;Привет из C/C++&quot;);
    return(1);
}


static const struct luaL_Reg R[] ={
    {&quot;TestFunc&quot;, forLua_TestFunc},
    {NULL, NULL}
};

extern &quot;C&quot;  LUA_API int  _stdcall luaopen_MyFun (lua_State *L)
{
luaL_openlib(L, &quot;MyFun&quot;, R, 0);
return (1);

}</code></pre></div><p>через программу&nbsp; PE Explorer проверил экспортируемые функции....<br />// Type&nbsp; &nbsp; &nbsp;: Exports<br />// luaopen_MyFun; Index 1;&nbsp; &nbsp; &nbsp; &nbsp; Information not available<br />// ___CPPdebugHook; Index 2;&nbsp; &nbsp; &nbsp; &nbsp; Information not available</p><br /><p>Затем написал вот такой скрипт Луа<br /></p><div class="codebox"><pre><code>require(&quot;MyFun&quot;)
message(tostring(MyFun.TestFunc()), 1)
function main()
end</code></pre></div><p>После запуска скрипта Квик выдает следующую ошибку...&quot;Unknown error. Possible unhandled exception.&quot;<br />Не понимаю в чем проблема(.</p>]]></content>
			<author>
				<name><![CDATA[Kirill.V]]></name>
				<uri>https://quik2dde.ru/profile.php?id=267</uri>
			</author>
			<updated>2015-05-03T10:24:24Z</updated>
			<id>https://quik2dde.ru/viewtopic.php?pid=1310#p1310</id>
		</entry>
</feed>
