久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <i id='7nhVc'><tr id='7nhVc'><dt id='7nhVc'><q id='7nhVc'><span id='7nhVc'><b id='7nhVc'><form id='7nhVc'><ins id='7nhVc'></ins><ul id='7nhVc'></ul><sub id='7nhVc'></sub></form><legend id='7nhVc'></legend><bdo id='7nhVc'><pre id='7nhVc'><center id='7nhVc'></center></pre></bdo></b><th id='7nhVc'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='7nhVc'><tfoot id='7nhVc'></tfoot><dl id='7nhVc'><fieldset id='7nhVc'></fieldset></dl></div>

    <legend id='7nhVc'><style id='7nhVc'><dir id='7nhVc'><q id='7nhVc'></q></dir></style></legend>
    • <bdo id='7nhVc'></bdo><ul id='7nhVc'></ul>
  2. <small id='7nhVc'></small><noframes id='7nhVc'>

    <tfoot id='7nhVc'></tfoot>
    1. 如何在 VS2010 中 SWIG?

      How to SWIG in VS2010?(如何在 VS2010 中 SWIG?)
    2. <i id='HZfbV'><tr id='HZfbV'><dt id='HZfbV'><q id='HZfbV'><span id='HZfbV'><b id='HZfbV'><form id='HZfbV'><ins id='HZfbV'></ins><ul id='HZfbV'></ul><sub id='HZfbV'></sub></form><legend id='HZfbV'></legend><bdo id='HZfbV'><pre id='HZfbV'><center id='HZfbV'></center></pre></bdo></b><th id='HZfbV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='HZfbV'><tfoot id='HZfbV'></tfoot><dl id='HZfbV'><fieldset id='HZfbV'></fieldset></dl></div>

            <tbody id='HZfbV'></tbody>
              • <bdo id='HZfbV'></bdo><ul id='HZfbV'></ul>

                <small id='HZfbV'></small><noframes id='HZfbV'>

                <legend id='HZfbV'><style id='HZfbV'><dir id='HZfbV'><q id='HZfbV'></q></dir></style></legend>
                <tfoot id='HZfbV'></tfoot>
                本文介紹了如何在 VS2010 中 SWIG?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                限時(shí)送ChatGPT賬號(hào)..

                大家好,我正在嘗試將我在 VS2010 (c++) 中創(chuàng)建的多文件項(xiàng)目 SWIG 轉(zhuǎn)換為 python.我設(shè)法鏈接了 Python26.lib 文件,并讓 SWIG 為我的主 .cpp 文件生成了一個(gè)包裝器 .cpp 文件.我已經(jīng)設(shè)置我的代碼來構(gòu)建一個(gè)擴(kuò)展名為 .pyd 的 .dll.

                這是我目前擁有的 .i 文件:

                %module HiveGPS%{#include "ou_thread.h"#include "HiveGPS.h"%}%include ou_thread.h% 包括 HiveGPS.h

                而且我已經(jīng)設(shè)法獲得了 .py 和 .pyc 文件.現(xiàn)在,根據(jù)我的理解,為了運(yùn)行我的 .py 文件,我需要將它鏈接到我的 .pyd 文件,但是當(dāng)我嘗試使用 VS2010 使用上面列出的設(shè)置構(gòu)建我的項(xiàng)目時(shí),它會(huì)抱怨我的 Thread 類正在使用:

                1>------ 構(gòu)建開始:項(xiàng)目:HiveGPS,配置:發(fā)布 Win32 ------1> 構(gòu)建于 2011 年 5 月 11 日下午 1:41:30 開始.1>初始化構(gòu)建狀態(tài):1>觸摸ReleaseHiveGPS.unsuccessfulbuild".1>Cl編譯:1>HiveGPS_wrap.cpp1>c:users*desktophivegpshivegpsou_thread.h(57):錯(cuò)誤 C2146:語法錯(cuò)誤:缺少;"在標(biāo)識(shí)符m_strName"之前1>c:users*desktophivegpshivegpsou_thread.h(57):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(57):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(64):錯(cuò)誤 C2146:語法錯(cuò)誤:缺少;"在標(biāo)識(shí)符getName"之前1>c:users*desktophivegpshivegpsou_thread.h(64):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(64):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(64):警告 C4183:'getName':缺少返回類型;假定是一個(gè)返回int"的成員函數(shù)1>c:users*desktophivegpshivegpsou_thread.h(98):錯(cuò)誤 C2146:語法錯(cuò)誤:缺少;"在標(biāo)識(shí)符m_strName"之前1>c:users*desktophivegpshivegpsou_thread.h(98):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(98):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(104):錯(cuò)誤C2146:語法錯(cuò)誤:缺少';'在標(biāo)識(shí)符getName"之前1>c:users*desktophivegpshivegpsou_thread.h(104):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(104):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(104):警告 C4183:'getName':缺少返回類型;假定是一個(gè)返回int"的成員函數(shù)1>c:users*desktophivegpshivegpsou_thread.h(115):錯(cuò)誤C2146:語法錯(cuò)誤:缺少';'在標(biāo)識(shí)符 'msg' 之前1>c:users*desktophivegpshivegpsou_thread.h(115):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(115):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(118):錯(cuò)誤C2146:語法錯(cuò)誤:缺少';'在標(biāo)識(shí)符getMessage"之前1>c:users*desktophivegpshivegpsou_thread.h(118):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(118):錯(cuò)誤 C4430:缺少類型說明符 - 假設(shè)為 int.注意:C++ 不支持 default-int1>c:users*desktophivegpshivegpsou_thread.h(118):警告 C4183:'getMessage':缺少返回類型;假定是一個(gè)返回int"的成員函數(shù)1>c:users*desktophivegpshivegpsou_thread.h(51): error C2011: 'openutils::Thread' : 'class' 類型重新定義1>c:users*desktophivegpshivegpsou_thread.h(51) :參見openutils::Thread"的聲明1>c:users*desktophivegpshivegpsou_thread.h(93): error C2011: 'openutils::Mutex' : 'class' 類型重新定義1>c:users*desktophivegpshivegpsou_thread.h(93) :參見'openutils::Mutex'的聲明1>c:users*desktophivegpshivegpsou_thread.h(113):錯(cuò)誤 C2011:'openutils::ThreadException':'class' 類型重新定義1>c:users*desktophivegpshivegpsou_thread.h(113) :參見openutils::ThreadException"的聲明1>c:users*desktophivegpshivegpsHiveGPS.h(29):錯(cuò)誤 C2504:'openutils::Thread':基類未定義1>c:users*desktophivegpshivegpsHiveGPS.h(53): error C2079: 'HiveGPS::readWriteMutex' 使用未定義的類 'openutils::Mutex'1>HiveGPS_wrap.cpp(3086):錯(cuò)誤 C2027:使用未定義類型openutils::Thread"1>c:users*desktophivegpshivegpsou_thread.h(51) :參見openutils::Thread"的聲明1>HiveGPS_wrap.cpp(3086):致命錯(cuò)誤C1903:無法從之前的錯(cuò)誤中恢復(fù);停止編譯1>1> 構(gòu)建失敗.1>1> 已用時(shí)間 00:00:02.10========== 構(gòu)建:0 成功,1 失敗,0 最新,0 跳過 ==========

                所有這些錯(cuò)誤(減去最后一個(gè))基本上都是說 String 類是以某種方式實(shí)現(xiàn)的,是否與 Python 對(duì) String 類的定義相沖突?最后一個(gè)錯(cuò)誤是抱怨 Thread 類,這可能是同樣的問題嗎?

                所有這些都說:有人能告訴我我做錯(cuò)了什么嗎,或者更好,請(qǐng)指點(diǎn)我如何為 VS2010 執(zhí)行此操作的教程(SWIG 站點(diǎn)是 2008 年的).

                如果不能這樣做,我可以將我生成的 .py 文件以某種方式鏈接到 .dll 文件嗎?

                抱歉解釋太長,但我對(duì)這個(gè)有點(diǎn)迷茫,所以我決定解釋一切.

                解決方案

                好的,我正在使用 swig 和 VS2010 沒有問題...

                就您而言,看起來更像是您在鏈接方面存在問題.除了檢查庫之外,不要忘記檢查您正在鏈接的 32-64 位庫.嘗試將所有作為 x86 目標(biāo)鏈接為故障安全.并且不要使用AnyCpu.

                <小時(shí)>

                如何在 VS2010 下使用 SWIG.

                讓我們定義您想要獲取 mylib.py,因此您創(chuàng)建了一些 SWIG 接口文件,其中 mylib.i 作為主"文件.我假設(shè)您已經(jīng)有了一個(gè)包含 C++ 類的項(xiàng)目解決方案.

                (1) 首先為 SWIG 接口創(chuàng)建 C++ 項(xiàng)目.使用應(yīng)該創(chuàng)建 C++ DLL 存根的 Visual C++-> 類庫項(xiàng)目.我把所有的 .i 文件放在那里.并將 Visual Studio 設(shè)置為將 .i 高亮顯示為 .h - 這很方便.

                (1.1) 將 mylib_wrap.cxx 文件添加到項(xiàng)目中(在 swig 尚未生成文件時(shí)創(chuàng)建一個(gè)空文件)

                (2)
                a) 在 mylib.i 上按右鍵,選擇屬性.
                b) 將 ItemType 設(shè)置為自定義構(gòu)建工具".
                在自定義構(gòu)建步驟窗口中:
                c) 命令行字段應(yīng)該是這樣的:

                echo 為了正常運(yùn)行,請(qǐng)確保以下環(huán)境變量是正確設(shè)置:回聲 PYTHON_INCLUDE:%PYTHON_INCLUDE%回聲 PYTHON_LIB:%PYTHON_LIB%回聲C:swigswig.exe -c++ -python %(FullPath)

                將 C:swigswig.exe 更改為 SWIG 的路徑

                d) 在輸出字段中:

                $(InputName)_wrap.cxx

                (3) 轉(zhuǎn)到此項(xiàng)目屬性:

                a) C++ 選項(xiàng)卡 -> 其他包含目錄
                添加 $(PYTHON_INCLUDE);...

                c) 鏈接器 -> 輸出文件
                你需要的路徑\_mylib.pyd

                d) 鏈接器 -> 啟用增量鏈接
                設(shè)置為否 (/INCREMENTAL:NO)

                e) 鏈接器 -> 輸入 -> 附加依賴
                添加 $(PYTHON_LIB);...

                f) C/C++ -> 預(yù)編譯頭:關(guān)閉預(yù)編譯頭文件,設(shè)置 **Not Using Precompiled Headers* 并在

                之后刪除 stdafx 文件

                g) 常規(guī)標(biāo)簽.只需檢查是否設(shè)置了這些:
                配置類型 = 動(dòng)態(tài)庫 (.dll)
                字符集 = 使用 Unicode 字符集
                公共語言運(yùn)行時(shí)支持 = 無公共語言運(yùn)行時(shí)支持

                它編譯.

                附言并且不要忘記在您的系統(tǒng)中設(shè)置 %PYTHON_INCLUDE% 和 %PYTHON_LIB% 變量.

                Hey Everybody, I'm trying to SWIG a multi file project that I made in VS2010 (c++) to python. I've managed to link the Python26.lib file, and have SWIG generating a wrapper .cpp file for my main .cpp file. I've set my code to build a .dll with the extension .pyd.

                This is the .i file I have currently:

                %module HiveGPS
                
                %{
                #include "ou_thread.h"
                #include "HiveGPS.h"
                %}
                
                
                %include ou_thread.h
                %include HiveGPS.h
                

                And I've mangaed to get a .py and .pyc file. Now, from my understanding in order to run my .py file, I need to link it to my .pyd file, but when I try to use VS2010 to build my project with the settings I listed above, it complains about a Thread class I'm using:

                1>------ Build started: Project: HiveGPS, Configuration: Release Win32 ------
                1>Build started 5/11/2011 1:41:30 PM.
                1>InitializeBuildStatus:
                1>  Touching "ReleaseHiveGPS.unsuccessfulbuild".
                1>ClCompile:
                1>  HiveGPS_wrap.cpp
                1>c:users*desktophivegpshivegpsou_thread.h(57): error C2146: syntax error : missing ';' before identifier 'm_strName'
                1>c:users*desktophivegpshivegpsou_thread.h(57): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(57): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(64): error C2146: syntax error : missing ';' before identifier 'getName'
                1>c:users*desktophivegpshivegpsou_thread.h(64): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(64): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(64): warning C4183: 'getName': missing return type; assumed to be a member function returning 'int'
                1>c:users*desktophivegpshivegpsou_thread.h(98): error C2146: syntax error : missing ';' before identifier 'm_strName'
                1>c:users*desktophivegpshivegpsou_thread.h(98): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(98): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(104): error C2146: syntax error : missing ';' before identifier 'getName'
                1>c:users*desktophivegpshivegpsou_thread.h(104): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(104): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(104): warning C4183: 'getName': missing return type; assumed to be a member function returning 'int'
                1>c:users*desktophivegpshivegpsou_thread.h(115): error C2146: syntax error : missing ';' before identifier 'msg'
                1>c:users*desktophivegpshivegpsou_thread.h(115): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(115): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(118): error C2146: syntax error : missing ';' before identifier 'getMessage'
                1>c:users*desktophivegpshivegpsou_thread.h(118): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(118): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
                1>c:users*desktophivegpshivegpsou_thread.h(118): warning C4183: 'getMessage': missing return type; assumed to be a member function returning 'int'
                1>c:users*desktophivegpshivegpsou_thread.h(51): error C2011: 'openutils::Thread' : 'class' type redefinition
                1>          c:users*desktophivegpshivegpsou_thread.h(51) : see declaration of 'openutils::Thread'
                1>c:users*desktophivegpshivegpsou_thread.h(93): error C2011: 'openutils::Mutex' : 'class' type redefinition
                1>          c:users*desktophivegpshivegpsou_thread.h(93) : see declaration of 'openutils::Mutex'
                1>c:users*desktophivegpshivegpsou_thread.h(113): error C2011: 'openutils::ThreadException' : 'class' type redefinition
                1>          c:users*desktophivegpshivegpsou_thread.h(113) : see declaration of 'openutils::ThreadException'
                1>c:users*desktophivegpshivegpsHiveGPS.h(29): error C2504: 'openutils::Thread' : base class undefined
                1>c:users*desktophivegpshivegpsHiveGPS.h(53): error C2079: 'HiveGPS::readWriteMutex' uses undefined class 'openutils::Mutex'
                1>HiveGPS_wrap.cpp(3086): error C2027: use of undefined type 'openutils::Thread'
                1>          c:users*desktophivegpshivegpsou_thread.h(51) : see declaration of 'openutils::Thread'
                1>HiveGPS_wrap.cpp(3086): fatal error C1903: unable to recover from previous error(s); stopping compilation
                1>
                1>Build FAILED.
                1>
                1>Time Elapsed 00:00:02.10
                ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
                

                All of these errors (minus the last one) are basically saying that the String class is implemented somehow, is it conflicting with Python's definition of the String class? The last error is complaining about the Thread class, could that be the same problem?

                All of that said: Can somebody tell me what I'm doing wrong, or better yet, point me to a tutorial of how to do this for VS2010 (the SWIG site is for 2008).

                And if that can't be done, can I link the .py file I have generated to the .dll file somehow?

                Sorry for the long explanation but I'm kinda lost on this one so I decided to explain everything.

                解決方案

                Ok, I'm using swig and VS2010 with no problems...

                In your case, it looks more like you have problems with linking. Beyond the check of libraries, dont forget to check 32-64 bit libraries you are linking. Try to link all as x86 target as fail-safe. And don't use AnyCpu.


                How to use SWIG under VS2010.

                lets define you want to obtain mylib.py, so you created some SWIG interface files with mylib.i as "main" file. I assume that you already have a solution with project with your C++ classes there.

                (1) First create C++ project for SWIG interface. Use Visual C++->Class library project which should create a C++ DLL stub. I put all .i files there. And set visual studio to highlight .i as .h - it is handy.

                (1.1) Add mylib_wrap.cxx file to the project (create empty file while swig hasn't generated one yet)

                (2)
                a) Press right button over the mylib.i, choose properties.
                b) set ItemType as "Custom build tool".
                In custom build step window:
                c) Command line field should be something like:

                echo In order to function correctly, please ensure the following environment variables are
                correctly set: 
                echo PYTHON_INCLUDE: %PYTHON_INCLUDE% 
                echo PYTHON_LIB: %PYTHON_LIB% 
                echo on 
                C:swigswig.exe -c++ -python %(FullPath) 
                

                change C:swigswig.exe to your path to SWIG

                d) In Outputs field:

                $(InputName)_wrap.cxx
                

                (3) Go to this project properties:

                a) C++ tab -> Additional Include Directories
                add $(PYTHON_INCLUDE); ...

                c) Linker -> Output File
                Path-You-Needed\_mylib.pyd

                d) Linker -> Enable Incremental Linking
                set as No (/INCREMENTAL:NO)

                e) Linker -> Input -> Additional Dependencies
                add $(PYTHON_LIB);...

                f) C/C++ -> Precompiled Headers: Switch off precompiled headers, set **Not Using Precompiled Headers* and remove stdafx files after

                g) General tab. Just check that these are set:
                Configuration type = Dynamic Library (.dll)
                Character set = Use Unicode Character Set
                Common Language Runtime Support = No Common Language Runtime Support

                It compiles.

                P.S. And dont forget to set %PYTHON_INCLUDE% and %PYTHON_LIB% variables in your system too.

                這篇關(guān)于如何在 VS2010 中 SWIG?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                Why do two functions have the same address?(為什么兩個(gè)函數(shù)的地址相同?)
                Why the initializer of std::function has to be CopyConstructible?(為什么 std::function 的初始化程序必須是可復(fù)制構(gòu)造的?)
                mixing templates with polymorphism(混合模板與多態(tài)性)
                When should I use the keyword quot;typenamequot; when using templates(我什么時(shí)候應(yīng)該使用關(guān)鍵字“typename?使用模板時(shí))
                Dependent name resolution amp; namespace std / Standard Library(依賴名稱解析命名空間 std/標(biāo)準(zhǔn)庫)
                gcc can compile a variadic template while clang cannot(gcc 可以編譯可變參數(shù)模板,而 clang 不能)

                  <small id='9VRRW'></small><noframes id='9VRRW'>

                    <i id='9VRRW'><tr id='9VRRW'><dt id='9VRRW'><q id='9VRRW'><span id='9VRRW'><b id='9VRRW'><form id='9VRRW'><ins id='9VRRW'></ins><ul id='9VRRW'></ul><sub id='9VRRW'></sub></form><legend id='9VRRW'></legend><bdo id='9VRRW'><pre id='9VRRW'><center id='9VRRW'></center></pre></bdo></b><th id='9VRRW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9VRRW'><tfoot id='9VRRW'></tfoot><dl id='9VRRW'><fieldset id='9VRRW'></fieldset></dl></div>

                  • <legend id='9VRRW'><style id='9VRRW'><dir id='9VRRW'><q id='9VRRW'></q></dir></style></legend>
                      <tbody id='9VRRW'></tbody>
                    • <bdo id='9VRRW'></bdo><ul id='9VRRW'></ul>

                          <tfoot id='9VRRW'></tfoot>
                          主站蜘蛛池模板: 亚洲一区色 | 91av在线免费观看 | 99自拍视频 | 96久久| 中文字幕av一区二区三区谷原希美 | 久草青青草 | 色www| 国产成人网 | 国产视频一区二区在线播放 | 婷婷综合五月 | 91久久精品日日躁夜夜躁欧美 | 一区二区三区在线看 | 免费成年人视频 | 日本欧美久久久久免费播放网 | 国产盗摄一区二区 | 午夜视频在线 | 黄色草逼视频 | 草草福利影院 | 午夜免费观看视频 | 可以免费看黄的网站 | 99一区二区三区 | 一级特黄妇女高潮 | 日韩欧美三区 | 欧洲一区二区三区 | 婷婷伊人网 | 奇米影视亚洲春色 | 国产日韩欧美精品 | 午夜黄色小视频 | 精品99视频| 欧美一区二区三区成人 | 欧美成人激情 | 香蕉看片| 欧美 日韩 国产 在线 | 精品久久网站 | 一区二区av | 99精品久久久久久 | 国产一区二区三区视频 | 国产精品免费一区 | 久久久一区二区三区 | 夜晚福利视频 | 欧美精品一区二区在线观看 |