xing's Blog

Give me a place to stand on, and I'll move the earth.

OpenCV related DLL in MinGW & VC 2005 Express

xing posted @ Thu, 08 Apr 2010 05:31:59 +0800 in C/C++ with tags c/c++ , 5531 readers

I used to MATLAB programming for a long time. I began to find an alternative when the limitations of it arise. I had focused on mixed programming which is still an interest of me. Using C/C++,Fortran,Lisp become a choice when I evaluated various integrated software environments more or less. OpenCV is a wonderful package for image processing and computer vision both in Widnows and in Linux. Linux has a much easier mechanism to develop and use shared library (dynamically linked library) than that in windows. I had planned use Linux as my working platform substituting windows for a long time. But even now I had to return to windows for some work because the surrounding environment is full of date and formats created with products of M$.  Fortunately there are lots of Linux tools which can be used in Windows. MingGW is on

e of them. Creating and Using DLL with MinGW and VC 2005 express , another free (no cost) compiler from M$, is discussed below.

comp.bat:
set path=f:\mingw\bin;%path%
rem mingw32 is used to produce shared library in windowsxp. test.c is the first simple source to succeed.
f:\mingw\bin\gcc  -shared  -DBUILDING_DLL -I"F:\Program Files\OpenCV\cxcore\include" -I"F:\Program Files\OpenCV\cv\include"  -I"F:\Program Files\OpenCV\cvaux\include" -I"F:\Program Files\OpenCV\ml\include" -I"F:\Program Files\OpenCV\otherlibs\highgui" test.c -L"F:\Program Files\OpenCV\lib"   -lcxcore -lcv -lcvaux -lml -lhighgui  -o test.so

rem test1.c is the complete source to create dll with opencv library. Function "main" can be imported from newlisp.
f:\mingw\bin\g++  -shared  -DBUILDING_DLL -I"F:\Program Files\OpenCV\cxcore\include" -I"F:\Program Files\OpenCV\cv\include"  -I"F:\Program Files\OpenCV\cvaux\include" -I"F:\Program Files\OpenCV\ml\include" -I"F:\Program Files\OpenCV\otherlibs\highgui" test1.cpp -L"F:\Program Files\OpenCV\lib"   -lcxcore -lcv -lcvaux -lml -lhighgui  -o test1.so

rem msvc2005express is used to produce dll
cl /LD /nologo /ML /EHsc /D"_MBCS"  /I"F:\Program Files\OpenCV\cxcore\include" /I"F:\Program Files\OpenCV\cv\include" /I"F:\Program Files\OpenCV\cvaux\include" /I"F:\Program Files\OpenCV\ml\include" /I"F:\Program Files\OpenCV\otherlibs\highgui" /I"F:\Program Files\Microsoft Visual Studio 8\VC\include" test1.cpp /link /libpath:"F:\Program Files\OpenCV\lib" /libpath:"F:\Program Files\Microsoft Visual Studio 8\VC\lib" cxcore.lib cv.lib cvaux.lib ml.lib highgui.lib

rem msvc2005express can produce a dll directly from the original source of bezier.cpp, but ther is no funciton can be exported and invoked by other program while mingw32 refused to produce such a dll.
cl /LD /nologo /ML /EHsc /D"_MBCS"  /I"F:\Program Files\OpenCV\cxcore\include" /I"F:\Program Files\OpenCV\cv\include" /I"F:\Program Files\OpenCV\cvaux\include" /I"F:\Program Files\OpenCV\ml\include" /I"F:\Program Files\OpenCV\otherlibs\highgui" /I"F:\Program Files\Microsoft Visual Studio 8\VC\include" bezier.cpp /link /libpath:"F:\Program Files\OpenCV\lib" /libpath:"F:\Program Files\Microsoft Visual Studio 8\VC\lib" cxcore.lib cv.lib cvaux.lib ml.lib highgui.lib


end of comp.bat
the line of invoking compiler is too long to be displayed in one line. But I'm not sure when it can work properly, and I gave up the effort to break it.



test1.c
# define DLLIMPORT __declspec (dllexport)
...
DLLIMPORT int main(int argc, char* argv[])
...

end of test1.c

in newLISP "main" function can be imported and invoked correctly:)

 

 

Avatar_small
Menhennitt said:
Mon, 22 Oct 2018 20:18:29 +0800

This open CV option is a valid solution for users from people gets lots of benefits in writing of mistake free works. Now students can use online writing service help for their best essay writing work that is very important for them.

Avatar_small
kiếm tiền với sàn We said:
Tue, 21 Jul 2020 19:13:19 +0800

Thank you again for all the knowledge you distribute,Good post. I was very interested in the article, it's quite inspiring I should admit. I like visiting you site since I always come across interesting articles like this one.Great Job, I greatly appreciate that.Do Keep sharing! Regards,

Avatar_small
máy triệt lông vĩnh said:
Sat, 25 Jul 2020 19:31:28 +0800

Thanks for this great post, i find it very interesting and very well thought out and put together. I look forward to reading your work in the future.

Avatar_small
quầy kệ siêu thị said:
Sat, 12 Sep 2020 22:05:54 +0800

I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post.

Avatar_small
fake grass sheffield said:
Tue, 12 Jan 2021 16:26:59 +0800

This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information...

Avatar_small
köksrenovering i Sto said:
Wed, 13 Jan 2021 19:36:58 +0800

Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts.

Avatar_small
Complete Biz Listing said:
Thu, 21 Jan 2021 14:05:47 +0800

Thanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us.

Avatar_small
Casey Biz Listings said:
Sat, 23 Jan 2021 16:17:49 +0800

If you set out to make me think today; mission accomplished! I really like your writing style and how you express your ideas. Thank you.

Avatar_small
Andy's Biz Listings said:
Mon, 25 Jan 2021 14:17:56 +0800

I am hoping the same best effort from you in the future as well. In fact your creative writing skills has inspired me.

Avatar_small
Business Listings said:
Tue, 26 Jan 2021 19:44:18 +0800

I have read your article, it is very informative and helpful for me.I admire the valuable information you offer in your articles. Thanks for posting it..

Avatar_small
Local Citations said:
Fri, 29 Jan 2021 16:12:04 +0800

Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!..

Avatar_small
smart iptv said:
Sat, 30 Jan 2021 23:56:14 +0800

This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information...

Avatar_small
iptv smarters said:
Mon, 01 Feb 2021 00:36:39 +0800

I just couldn't leave your website before telling you that I truly enjoyed the top quality info you present to your visitors? Will be back again frequently to check up on new posts.

Avatar_small
what is educational said:
Tue, 02 Feb 2021 00:12:44 +0800

Exactly, you're very kind of us about comment!.

Avatar_small
BEST SEO ONLINE said:
Wed, 03 Feb 2021 01:03:34 +0800

I’ve been searching for some decent stuff on the subject and haven't had any luck up until this point, You just got a new biggest fan!..

Avatar_small
Dịch vụ Marketing On said:
Wed, 03 Feb 2021 22:17:47 +0800

Thanks for this great post, i find it very interesting and very well thought out and put together. I look forward to reading your work in the future.

Avatar_small
Fire Watch Guards said:
Fri, 05 Feb 2021 01:10:35 +0800

Wonderful article, thanks for putting this together! This is obviously one great post. Thanks for the valuable information and insights you have so provided here.

Avatar_small
FIEX Marketing said:
Sat, 06 Feb 2021 19:49:00 +0800

Hi! Thanks for the great information you have provided! You have touched on crucuial points!

Avatar_small
Reclaim Physical The said:
Sun, 07 Feb 2021 23:19:49 +0800

I have read your article, it is very informative and helpful for me.I admire the valuable information you offer in your articles. Thanks for posting it..

Avatar_small
Modesto concert said:
Mon, 08 Feb 2021 19:12:37 +0800

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

Avatar_small
Erbn Green said:
Tue, 16 Feb 2021 23:46:28 +0800

I think this is one of the most significant information for me. And i’m glad reading your article. But should remark on some general things, The web site style is perfect, the articles is really great : D. Good job, cheers

Avatar_small
Carl Scholz said:
Fri, 19 Feb 2021 14:42:55 +0800

Just admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet!

Avatar_small
Arborist Townsville said:
Sun, 28 Feb 2021 19:26:19 +0800

I know your expertise on this. I must say we should have an online discussion on this. Writing only comments will close the discussion straight away! And will restrict the benefits from this information.

Avatar_small
FIEX Agency said:
Fri, 05 Mar 2021 15:48:04 +0800

this is really nice to read..informative post is very good to read..thanks a lot!

Avatar_small
coffee equipment said:
Fri, 05 Mar 2021 19:06:49 +0800

Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing

Avatar_small
car repairs woolloon said:
Sun, 07 Mar 2021 17:18:22 +0800

Very useful post. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up.

Avatar_small
rent tables and chai said:
Sun, 07 Mar 2021 19:03:29 +0800

I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post.

Avatar_small
My Little Pony color said:
Tue, 09 Mar 2021 21:16:26 +0800

Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best.

Avatar_small
KAI Asset Management said:
Mon, 15 Mar 2021 01:13:25 +0800

Thank you again for all the knowledge you distribute,Good post. I was very interested in the article, it's quite inspiring I should admit. I like visiting you site since I always come across interesting articles like this one.Great Job, I greatly appreciate that.Do Keep sharing! Regards,

Avatar_small
Autohändler Essen said:
Tue, 16 Mar 2021 15:40:04 +0800

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog, I will keep visiting this blog very often.

Avatar_small
Autoankauf Essen said:
Tue, 16 Mar 2021 15:40:34 +0800

This is a good post. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good works.

Avatar_small
KC SanPedro said:
Mon, 22 Mar 2021 03:02:31 +0800

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info.

Avatar_small
our website said:
Thu, 25 Mar 2021 14:54:39 +0800

Great articles and great layout. Your blog post deserves all of the positive feedback it’s been getting.

Avatar_small
Billings Montanta pl said:
Thu, 08 Apr 2021 19:50:51 +0800

Nice post. I was checking constantly this blog and I’m impressed! Extremely useful info specially the last part I care for such information a lot. I was seeking this certain info for a long time. Thank you and good luck.

Avatar_small
investing stock mark said:
Fri, 09 Apr 2021 15:30:34 +0800

This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It is the old what goes around comes around routine.

Avatar_small
Vlone said:
Sat, 10 Apr 2021 23:32:29 +0800

It’s appropriate time to make some plans for the future and it is time to be happy. I have read this post and if I could I wish to suggest you few interesting things or advice. Perhaps you could write next articles referring to this article. I desire to read even more things about it!

Avatar_small
dig this said:
Mon, 12 Apr 2021 15:21:09 +0800

I am unable to read articles online very often, but I’m glad I did today. This is very well written and your points are well-expressed. Please, don’t ever stop writing.

Avatar_small
famous world people said:
Tue, 13 Apr 2021 02:43:42 +0800

Nice post. I was checking constantly this blog and I’m impressed! Extremely useful info specially the last part I care for such information a lot. I was seeking this certain info for a long time. Thank you and good luck.

Avatar_small
Vlone Palm Angels te said:
Wed, 14 Apr 2021 22:48:25 +0800

Thank you a bunch for sharing this with all of us you actually realize what you are talking about! Bookmarked. Please also seek advice from my site =). We could have a hyperlink change contract between us!


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter