Saturday, November 07, 2009

MSVC and MinGW DLLs | MinGW

MSVC and MinGW DLLs | MinGW
Assume we have a testdll.h, testdll.c, and testmain.c. In the first case, we will compile testdll.c with MinGW, and let the MSVC-compiled testmain call it. You should use

gcc -shared -o testdll.dll testdll.c -Wl,--output-def,testdll.def,--out-implib,libtestdll.a

to produce the DLL and DEF files. MSVC cannot use the MinGW library, but since you have already the DEF file you may easily produce one by the Microsoft LIB tool:

lib /machine:i386 /def:testdll.def

Once you have testdll.lib, it is trivial to produce the executable with MSVC:

cl testmain.c testdll.lib

Now for MinGW programs calling an MSVC DLL. We have two methods. One way is to specify the LIB files directly on the command line after the main program. For example, after

cl /LD testdll.c

use

gcc -o testmain testmain.c testdll.lib

The other way is to produce the .a files for GCC. For __cdecl functions (in most cases), it is simple: you only need to apply the reimp tool from Anders Norlander (since his web site is no longer available, you may choose to download [this version|http://jrfonseca.dyndns.org/projects/gnu-win32/software/reimp/index.html] enhanced by Jose Fonseca):

reimp testdll.lib
gcc -o testmain testmain.c -L. -ltestdll

However, for __stdcall functions, the above method does not work. For MSVC will prefix an underscore to __stdcall functions while MinGW will not. The right way is to produce the DEF file using the pexports tool included in the mingw-utils package and filter off the first underscore by sed:

pexports testdll.dll | sed "s/^_//" > testdll.def

Then, when using dlltool to produce the import library, add `-U' to the command line:

dlltool -U -d testdll.def -l libtestdll.a

And now, you can proceed in the usual way:

gcc -o testmain testmain.c -L. -ltestdll

Hooray, we got it.

Tuesday, November 03, 2009

Build OpenCV 2.0.0a as static library

In MSVC++ 2008...

Use CMAKE to generate project files

From project files...

1. Change DLL option to LIB
2. Change OUTPUT folder to ..\..\lib\($env)\($projectName)200($d).lib

HIGHGUI200.LIB may build but no use (looking for solution now)...

Alternatevely use shared library of HIGHGUI200.LIB and place CXCORE200.DLL and HIGHGUI200.DLL on the path

To Compile custom project, make sure change /MT(d) to /MD(d) in compiler option and set /NODEFAULTLIB:"libcmt(d).lib"

Build Qt as static library

set qmakespec=(win32-g++ or win32-msvc2008 ...)
configure -release -static -no-exceptions -graphicssystem opengl -nomake examples -nomake demos

Open CV 1.1pre1 MINGW 5.1.6 (GCC 3.4.5) Compile

ren bin bin_original // back up original files
ren lib lib_original // back up original files
cd _make
mingw32-make -f make_all_gnu.mak // for release version
set DEBUG=1
mingw32-make -f make_all_gnu.mak // for debug version

Thursday, September 24, 2009

네이버 로그인을 즐겨찾기로 한번에

http://nid.naver.com/nidlogin.login?id=YOURID&pw=YOURPASSWORD&url=http://cafe.naver.com/opencv

Thursday, August 27, 2009

snoopy : 윈도우 7 홈 프리미엄 버전에 언어팩 설치하기

snoopy : 윈도우 7 홈 프리미엄 버전에 언어팩 설치하기: "dism /online /add-package /packagepath:d:\lp.cab"
제가 해보니까 언어팩 설치는 윈도우 상에서 가능한데 국가별 설정 변경은 윈도우 상에서 되지 않았습니다. 따라서 윈도우 7 DVD로 부팅을 해주셔야 합니다. 윈도우 7 DVD로 부팅하신 다음 처음 화면에서 Shift + F10 을 눌러서 명령 프롬프트를 띄웁니다. 그리고 다음과 같이 입력합니다.



dism /image:d: /set-skuintldefaults:ko-kr

다시 재부팅해서 윈도우에 진입을 해보면 키보드, 표시언어, 로케일을 포함한 모든 설정이 한글판으로 되어있을 것입니다. 따로 제어판에서 추가로 작업해주실 내용은 없습니다. 그런데 아마 부팅 화면 애니메이션은 그대로 영어로 남아있을 것입니다. 따라서 다시 명령 프롬프트를 관리자 권한으로 띄워주셔서 다음 2개의 명령어를 입력합니다.



bcdedit /set {bootmgr} locale ko-kr



bcdedit /set {current} locale ko-kr



그러면 이제 멀티부팅 화면이나 부팅 애니메이션이 한글판으로 잘 나올 것입니다.

Saturday, August 22, 2009

Silverglaze » Canon PowerShot S45 and Windows Vista

Silverglaze » Canon PowerShot S45 and Windows Vista

Canon PowerShot S45 and Windows Vista
Filed under: Useful Tech Tips — Jeffito @ 9:40 pm

250px-Canon_PowerShot_S45I discovered after I installed vista that Canon had not yet provided any vista drivers for the Canon PowerShot S45. I tried using a few other programs and nothing seemed to work to get my images off the camera. Luckily I have other laptops with XP and I have always just used these XP machines to get my images, but today I was stuck at home with just my vista laptop.

I was about to give up when I thought of something….. my iPod. I had bought an ipod camera connector to get my images off my camera when I am traveling. So I just hooked it up and transferred the pictures from the S45 to the iPod. I then plugged my iPod into my Windows Vista Laptop, opened windows explorer and then surfed to the DCIM folder on my iPod and the images were there for me to move to my hard drive… and eventually to Flickr.

Not a solution for everyone…. but it saved me from spending $40 on a USB flash card reader.

Tuesday, May 12, 2009

bv2.co.uk » Blog Archive » Visual Studio 2008 and CUDA

CUDA with Visual Studio 2008

bv2.co.uk » Blog Archive » Visual Studio 2008 and CUDA

Visual Studio 2008 and CUDA

As promised I received my Visual Studio 2008 on Friday from polyhedron and set about installing it on Saturday. This post will describe how to get VS 2008 to work with CUDA. I use CUDA 2.2 which is still under NDA so I wont be making any comments about its performance improvements today. Rather I will describe how to set up syntax highlighting, building and Intellisense.

Visual Studio is now distributed in DVD format which makes the installation process much easier due to not having to swop disks every few minutes. The installation went smoothly and quickly as I had the prerequisites (.net etc) installed already. I usually install software on my D drive and it didn’t have any complaints or issues with that either.

I already had the CUDA 2.2 SDK and toolkit installed along with the 185 drivers so I could move directly to configuring my Visual Studio to use CUDA:

Syntax highlighting: By default a .cu file is displayed all in black which makes editing rather tricky. NVidia supply a usertype.dat file which you will find under: “NVIDIA Corporation\NVIDIA CUDA SDK\doc\syntax_highlighting\visual_studio_8″ copy this file to: “\Program Files\Microsoft Visual Studio 9.0\Common7\IDE”. Now open up Visual Studio and navigate to: tools->options->text editor->file extension. In the extension box type “cu”, make sure you select “Microsoft Visual C++” in the drop down and not the default of “Microsoft Visual C#”. If you do select the C# one they syntax highlighting will still work but you wont see all the “__syncthreads()” etc highlighted.

Building: This is rather simple to configure, you can either specify the standard “nvcc ” command line for each .cu file in your project by right clicking ->properties->custom build. A better solution is to select a custom build rule for your project by selecting “project -> custom build rules -> find existing”. Again NVidia supply a rules file which you will find under the “\NVIDIA Corporation\NVIDIA CUDA SDK\common” directory. Select this build rule in your project properties and it makes it much easier to configure options for your building of CUDA projects.

Intellisense: Getting intellisense to work on .cu and .cuh files proved to be the most tricky step. I don’t actually use it very much as I try and keep my code fairly simple but its still nice to have when you can’t remember parameters etc. Logically I thought by adding .cu to the file extensions lists in the options wherever there was .c,.cpp etc listed and by the step used in enabling syntax highlighting it would just magically work. Sadly this was not the case. I did find a suggestion on the web mentioning a process that would enable it but it seemed rather clumsy to me. It involves writing your CUDA code in a .c file and then just as you hit compile a pre-build step copies the .c file to a .cu extension. To me it seemed odd that the Intellisense would work with .c,.cpp,.h etc and not with .cu where it is clearly just a different extension but essentially C code. As I ran out of option dialogs in Visual Studio I decided to look in the registry. After about 15 minutes I found what turned out to be the key. The “fix” is really simple: open the registry editor and navigate to “HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Languages\Language Services\C/C++” then go to the string entry “NCB Default C/C++ Extensions” and add “;.cu;.cuh” to the end of the list. Restart Visual Studio and Intellisense will work for your CUDA files. Keep in mind it doesnt know about CUDA specific extensions but will still help with all the normal C bits.

Saturday, February 28, 2009

Sony PS3Eye Camera DirectShow Capture Source Filter *Update* v2.1.0.0130 « AlexP’s Weblog

Sony PS3Eye Camera DirectShow Capture Source Filter *Update* v2.1.0.0130 « AlexP’s Weblog: "Manual removal of PS3Eye.ax and PS3EyeLib.dll files:

- Close any program that are using PS3Eye camera.
- Press ‘WinKey’+R on your keyboard or alternatively go to Start->Run
- Type the following: regsvr32 /u “C:\Program Files\AlexP\PS3Eye.ax”
- You will see the following dialog box confirming successful un-registration of the PS3Eye.ax file."