View Full Version : Compile AVisynth, How do I made a Dll version?
Jeremy Duncan
19th February 2009, 18:13
A guide to how to make dll's using visual c++ 2008 express edition.
1.) Software.
install Visual 2008 professional edition 90 day trial in the default c: location.
http://www.microsoft.com/downloads/details.aspx?FamilyID=83c3a1ec-ed72-4a79-8961-25635db0192b&displaylang=en
Install the 'Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5'.
http://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF
In the 'C:\Program Files\Microsoft Visual Studio 9.0\VC' folder in a new folder called PlatformSDK
this folder: C:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK
2.) Update the visual studio vc++ directory.
Open Visual Studio,tools, options, projects and solutions, vc++ directories,'show directories for include files'.
- Put this line at the top of the list.
$(WindowsSdkDir)\Samples\Multimedia\DirectShow\BaseClasses
here's a picture
http://img6.imageshack.us/img6/3035/include.th.jpg (http://img6.imageshack.us/my.php?image=include.jpg)
Add numbers which is useful for debugging.
Open Visual Studio,tools, options, text editor, c/c++, general. check mark the Line numbers box.
3.) Errors and how to fix them.
strmbase.lib error.
1. Open the Windows SDK CMD shell (Start > All Programs > Windows SDK v6.1 > SDK CMD Shell).
2. Type:
setenv /release
3. The CMD shell will switch from yellow text (debug) to green text (release).
4. In cmd prompt.
Type:
cd C:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\Samples\Multimedia\DirectShow\BaseClasses
This will go to the baseclasses folder like so:
C:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\Samples\Multimedia\D
irectShow\BaseClasses>
5. Now type:
vcbuild /upgrade
This will update the project. Looks like so.
C:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\Samples\Multimedia\D
irectShow\BaseClasses>vcbuild /upgrade
6. Build your sample as you usually do:
First Build a .vcproj by typing
vcbuild baseclasses.vcproj /platform=win32
Second Build a .sln file by typing
msbuild baseclasses.sln /p:platform=win32
This will make strmbasd and strmbase in two folders in the baseclasses folder.
Move strmbasd.lib and strmbase.lib to the C:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK\lib folder.
'ddraw.lib' error.
Find this at C:\Program Files\Windows Mobile 5.0 SDK R2\PocketPC\Lib\ARMV4I
Put it in the same lib folder you put strmbasd.lib and strmbase.lib in.
___________________ Now you've setup visual studio 2008 edition and your ready to make a dll___________________
How to open soundtouch and avisynth with visual studio to begin.
1.)
Unzip the avisynth folder.
2.)
Open Visual studio. File, Open, File, Avisynth folder, src, avisynth.dsw.
3.)
- Right click "Solution ___ (project)" And click configuration manager. Set configuration manager to build.
4.)
- merged the libs from directshow to avisynth.
Directshow properties, configuration properties, linker, input.
5.)
all projects made with these. All projects have these settings
Right click the project and click properties.
one.) _CRT_SECURE_NO_WARNINGS;
Project -> properties -> Configuration properties -> C/C++ -> preprocessor
two.) multithreaded dll
Project -> properties -> Configuration properties -> C/C++ -> Code Generation
three.)
Project -> properties -> Configuration properties -> C/C++ -> Language -> Force Conformance In For loop Scope -> No (/Zc:forScope-)
four.)
Project -> properties -> Configuration properties -> C/C++ -> Browse Information -> Enable Browse Information -> None.
6.)
highlighted the soundtouch, softwire, pfc libs.
From the build menu, project only, I choose "build only", then I choose pfc, soundtouch, softwire, the at the very end i choose build only avisynth.
7.) To make soundtouch.lib, pfc, softwire libs. I fixed the code here:
Firfilter.cpp, line 180
from -> resultDivider = (SAMPLETYPE)::pow(2, resultDivFactor);
to -> resultDivider = (SAMPLETYPE)pow((double)2, (double)resultDivFactor);
text-overlay.cpp, fix errors
Line 387
from -> const double scale = 516*64/sqrt(128);
to -> const double scale = 516*64/sqrt(128.0);
line 389.
from -> gamma[i]=unsigned short(sqrt(i) * scale + 0.5); // Gamma = 2.0
to -> gamma[i]=unsigned short(sqrt((double)i) * scale + 0.5); // Gamma = 2.0
Assembler.cpp, fix errors
line 1
#include <stdio.h>
#include <stdarg.h>
line 197
from -> const int t = time(0);
to -> time_t const t = time(0);
line 198
from -> fprintf(file, "\n;%s\n", ctime((long*)&t));
to -> fprintf(file, "\n;%s\n", ctime(&t));
If I don't make all projects multithreaded dll, I get problems.
If I build debug versions of the lib's or the final avisynth project, the dll will run very slowly.
If I build tcp deliver it asks to use mfc for dll, and if I do that many errors appear.
If I get a error that says use nodefaultlib, one of my files is not usinf multithreaded dll.
If I clean a build then the file I can build with that project gets deleted along with the other files used to build that project.
If other projects are unloaded then only the loaded project files gets deleted.
Check out my youtube channel for a video walkthrough.
It's in three videos: visual studio parts 1, 2, 3.
link (http://www.youtube.com/foxhoundfan)
dll and buildlog. Sunday March 8, 2009 (http://files.filefront.com/dll+and+buildlogzip/;13430130;/fileinfo.html)
Wilbert
19th February 2009, 20:04
Good that you got working! Sorry, i don't have time to read it all, but did you do something differently as described on the wiki? What is incorrect?
Jeremy Duncan
20th February 2009, 01:52
"Add the paths to the appropriate subsection:"
- I first deleted the paths in there then added the: bin, lib, include from the "Microsoft SDKs" folder in programs.
This brought many could not find dll messages.
I had to delete a file to get the default code in the subsections.
Then I had to search my pc to find out where each path should go.
If I got a dll error when I tried to build, I searched my pc, found the visual studio folder it was in, then linked to it in the path.
I wish the wiki had warned me of this.
But it worked out. Now I just have to figure out how to get the avisynth h files and stuff I need.
Also, the wiki guide doesn't tell me what files go in each section.
What goes in the h files is h files, and source files is for the avisynth source files, but what is "Resource" for? :)
I'm a bit busy for a while and can't fiddle with building a dll but would like somebody to tell me which files a needed or a sime way to build a dll with the sw I mentioned. :)
Fizick
20th February 2009, 11:30
I updated wiki a little. But IMO, not every usual user must compile avisynth yoursellf :)
Gavino
22nd February 2009, 16:23
0.)
The h file code.
If the code #include "file.h" is #include "...\file.h", it won't work.
Delete the part from the h file code "...\",so it's #include "file.h".
Editing the source files seems like a bad idea to me. Better to maintain the hierarchic folder structure for the source files as found in Avisynth_258_src.zip.
Fizick
22nd February 2009, 22:47
IMO, it is bad idea to edit the first post. it is a forum, not wiki.
if you want update, do not delete your original post text.
Gavino
23rd February 2009, 11:23
The dot dot dot causes a error message though.
Edit out the dot dot dots and them put them into my project folder.
dot dot dot ???
Are you referring to lines like: #include "../internal.h" ?
I assume you know the two dots refers to the parent folder? (If not, you shouldn't be messing with this stuff.)
The source files should be in a folder hierarchy like this:
distrib
src
|- audio
|- convert
|- core
|- filters
|- plugins
|- sources
etc (lower levels not shown)
If you set it up this way (as intended) you should not need to edit anything.
Guest
26th February 2009, 05:47
Anyway. I'm hoping somebody tells me which dll's are needed to make avisynth.dll 2.5.8 version. Why can't you figure that out from your linker errors? Are you saying the Avisynth source code project files are defective?
Guest
27th February 2009, 00:45
Jeremy, with all due respect, you just don't seem to know what you are doing. You're just floundering, breaking all the rules of organized development. That's why no developer wants to help you.
Jeremy Duncan
1st March 2009, 06:44
I have been busy trying to make my avisynth .dll and here is what I found out.
- afxres, used by the .rc. Is not for free, only in the visual studio you pay for.
I downloaded the visual studio 2008 professional 90 day trial and there the afxres file was and it didn't even need to be linked too specially.
- Second. After reading the compile avisynth thread I see I should open the file ' .dsw'. This will then load the nessessary avisynth files into my project.
I have been busy adding the files it needs into the include folder.
I see the " 1>BSCMAKE: error BK1506 : cannot open file '.\Debug\directshow_source.sbr': No such file or directory" error and will try and get that fixed.
I had to reformat my pc as it had the express version files in the registry and when I install the pro trial I didn't want a error due to sw version conflict.
That's why it's taken so long to post back.
- I have found that the files I need to include to the include folder have special names that can be seen when you open the folder asking for them. I have been adding any one if there were multiple copies...so i will ghost my pc and restart gathering the nessessary include files making sure I have the correct ones.
- The professional version of visual studio is setup the same way as in the videos I made.
I will post again sometimes tommorow night, 24 hours or so from now and tell you how I did. :)
Edit,
And the professional version fixes many error messages I had with the free version.
Edit,
I deleted my other posts because I didn't want to be told I posted too much in this thread.
I hope that was ok.
I won't delete this post though, as it has valuable info.
Edit,
Well it's been about 24 hours since I first posted this.
I have learned two new things:
- This line should be in the vc++ directory, include section.
$(WindowsSdkDir)\Samples\Multimedia\DirectShow\BaseClasses
It should be above this line:
$(WindowsSdkDir)\include
This will remove many errors and needing to add files to the include folder.
- If I didn't make myself clear before, you unzip the avisynth scr folder, then in the src folder you open the avisynth.dsw file using visual studio file tab.
This will get all the files nessessary.
You do still need to set each main folder in this project to use multichar and static mfc.
- Finally the main reason I'm posting. The visual studio ' baseclasses' folder does not have the makefile file.
I need this to get past a error. I would use the visual studio command prompt and the makefile with nmake to fix this error.
But the file makefile it does not have?
Previous versions of visual studio and the sdk did have it, or so google says, but not this fancy dancy version. :rolleyes:
So I can not make the avisynth dll with the free version because the free version does not have afxres, and the pay version does not have makefile in the baseclasses folder.
I can do no more other than wait for MS to fix this bug.
:p
Guest
1st March 2009, 15:39
Don't try to build DirectShow stuff. Just link to its libraries.
Jeremy Duncan
4th March 2009, 02:30
Don't try to build DirectShow stuff. Just link to its libraries.
I can't find the option to disable directshow from building.
I can arrange the order they are built, but not disable one from being built.
I would like you to explain how you do this so I could look in this new sw and see if it has that option or something similar. :)
Guest
4th March 2009, 04:43
Sorry, but you've painted yourself into a corner and I can't work from that position. :)
Jeremy Duncan
4th March 2009, 16:52
I have today succeeded in my attempt to debug my project without any major errors that stop the debugging.
I do have a buildlog that shows many errors though. The way avisynth is written it has errors.
I will now post the link to my errors in my build log. Please download it and see what you can see and offer any advice.
http://www.megaupload.com/?d=R51U5H65
File size: 4.53 KB
This buildlog is for the official avisynth 2.5.8
I have updated my first post to show how I did this.
I have made some youtube videos showing a walkthrough of the first post. See first post for link to youtube.
I hope somebody reads the buildlog I uploaded.
Leak
4th March 2009, 17:24
I do have a buildlog that shows many errors though. The way avisynth is written it has errors.
That's called progress, or some variation thereof.
Earlier versions of Microsoft's C/C++ compiler had more lax scoping rules, but now variables declared in a for loop aren't visible outside of the loop anymore.
Go to "C/C++ > Language" in the AviSynth project's properties and set "Force Conformance In For Loop Scope" to "No", that (for now) takes care of all those errors.
The two calls to "sqrt()" need a cast to double for their parameters, SoundTouch has an additional "/I" parameter under "C/C++ > Commandline" that needs to be deleted (probably the project conversion gone wrong), and Softwire at one point uses "long*" for a cast when it really should use "time_t*", which at one point might have been the same type in the end...
Just uncheck DirectShowSource, pfc and TCPDeliver under "Build > Configuration Manager" and it should compile fine.
np: Homelife - Seedpod (You Don't Know Ninja Cuts (Disc 3))
Jeremy Duncan
4th March 2009, 23:27
That's called progress, or some variation thereof.
Earlier versions of Microsoft's C/C++ compiler had more lax scoping rules, but now variables declared in a for loop aren't visible outside of the loop anymore.
Go to "C/C++ > Language" in the AviSynth project's properties and set "Force Conformance In For Loop Scope" to "No", that (for now) takes care of all those errors.
The two calls to "sqrt()" need a cast to double for their parameters, SoundTouch has an additional "/I" parameter under "C/C++ > Commandline" that needs to be deleted (probably the project conversion gone wrong), and Softwire at one point uses "long*" for a cast when it really should use "time_t*", which at one point might have been the same type in the end...
Just uncheck DirectShowSource, pfc and TCPDeliver under "Build > Configuration Manager" and it should compile fine.
np: Homelife - Seedpod (You Don't Know Ninja Cuts (Disc 3))
Thank you very much for your advise. I have only two errors. The underlined parts of your quote I have done.
I will post my buildlog: Link (http://www.megaupload.com/?d=SROGJWUA)
text-overlay.cpp
.\filters\text-overlay.cpp(387) : error C2668: 'sqrt' : ambiguous call to overloaded function
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(581): could be 'long double sqrt(long double)'
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(533): or 'float sqrt(float)'
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(128): or 'double sqrt(double)'
while trying to match the argument list '(int)'
.\filters\text-overlay.cpp(389) : error C2668: 'sqrt' : ambiguous call to overloaded function
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(581): could be 'long double sqrt(long double)'
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(533): or 'float sqrt(float)'
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(128): or 'double sqrt(double)'
while trying to match the argument list '(int)
Leak
5th March 2009, 00:13
text-overlay.cpp
.\filters\text-overlay.cpp(387) : error C2668: 'sqrt' : ambiguous call to overloaded function
The two calls to "sqrt()" need a cast to double for their parameters
There's a C/C++ language reference that comes with VC++. I'd suggest you read it.
np: Telefon Tel Aviv - The Birds (Immolate Yourself)
Jeremy Duncan
5th March 2009, 09:13
That code and error I posted before was wrong. I got confused and so I had to go back and just fix the error Leak mentioned, but the other error I still don't know how to fix.
Here is the error message.
1>Compiling...
1>text-overlay.cpp
1>.\filters\text-overlay.cpp(389) : error C2668: 'sqrt' : ambiguous call to overloaded function
1> c:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(581): could be 'long double sqrt(long double)'
1> c:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(533): or 'float sqrt(float)'
1> c:\Program Files\Microsoft Visual Studio 9.0\VC\include\math.h(128): or 'double sqrt(double)'
1> while trying to match the argument list '(int)'
1>.\filters\text-overlay.cpp(1329) : warning C4018: '<' : signed/unsigned mismatch
1>Build log was saved at
This is line # 389
gamma[i]=unsigned short(sqrt(i) * scale + 0.5); // Gamma = 2.0
here is the full section of code that gives that error.
void Antialiaser::GetAlphaRect() {
dirty = false;
static BYTE bitcnt[256], // bit count
bitexl[256], // expand to left bit
bitexr[256]; // expand to right bit
static bool fInited = false;
static unsigned short gamma[129]; // Gamma lookups
if (!fInited) {
fInited = true;
int i;
const double scale = 516*64/sqrt(128.0);
for(i=0; i<=128; i++)
gamma[i]=unsigned short(sqrt(i) * scale + 0.5); // Gamma = 2.0
for(i=0; i<256; i++) {
BYTE b=0, l=0, r=0;
if (i& 1) { b=1; l|=0x01; r|=0xFF; }
if (i& 2) { ++b; l|=0x03; r|=0xFE; }
if (i& 4) { ++b; l|=0x07; r|=0xFC; }
if (i& 8) { ++b; l|=0x0F; r|=0xF8; }
if (i& 16) { ++b; l|=0x1F; r|=0xF0; }
if (i& 32) { ++b; l|=0x3F; r|=0xE0; }
if (i& 64) { ++b; l|=0x7F; r|=0xC0; }
if (i&128) { ++b; l|=0xFF; r|=0x80; }
bitcnt[i] = b;
bitexl[i] = l;
bitexr[i] = r;
}
}
Edit. I fixed the Error, but I still get a warning. but that's ok I think.
here is the modified code that fixes the error from above.
void Antialiaser::GetAlphaRect() {
dirty = false;
static BYTE bitcnt[256], // bit count
bitexl[256], // expand to left bit
bitexr[256]; // expand to right bit
static bool fInited = false;
static unsigned short gamma[129]; // Gamma lookups
if (!fInited) {
fInited = true;
int i;
const double scale = 516*64/sqrt(128.0);
for(i=0; i<=128; i++)
gamma[i]=unsigned short(sqrt((double)i) * scale + 0.5); // Gamma = 2.0
for(i=0; i<256; i++) {
BYTE b=0, l=0, r=0;
if (i& 1) { b=1; l|=0x01; r|=0xFF; }
if (i& 2) { ++b; l|=0x03; r|=0xFE; }
if (i& 4) { ++b; l|=0x07; r|=0xFC; }
if (i& 8) { ++b; l|=0x0F; r|=0xF8; }
if (i& 16) { ++b; l|=0x1F; r|=0xF0; }
if (i& 32) { ++b; l|=0x3F; r|=0xE0; }
if (i& 64) { ++b; l|=0x7F; r|=0xC0; }
if (i&128) { ++b; l|=0xFF; r|=0x80; }
bitcnt[i] = b;
bitexl[i] = l;
bitexr[i] = r;
}
}
Edit. After I fixed the above error, I was asked for soundtouch.lib.
I read at the mediawiki that soundtouch.lib must be made. When I tried to make it I found a error that prevented me from making it. I found the solution and will post it.
Firfilter.cpp line 184
Change the line
from -> resultDivider = (SAMPLETYPE)pow(2, resultDivFactor);
to -> resultDivider = (SAMPLETYPE)pow((double)2, (double)resultDivFactor);
Then I was asked for pfc.lib. Which I also made, from the avisynth src.
Then I was told Assembler.cpp had a error.
I did this. At the first line of assembler .cpp I added these two includes.:
#include <stdio.h>
#include <stdarg.h>
Then, after adding those includes. I changed the code at these lines: 197, 198.
I removed the code that was there and instead put this code there.
time_t const t = time(0);
fprintf(file, "\n;%s\n", ctime(&t));
This is my current buildlog with a host of errors.
link (http://www.megaupload.com/?d=84A2HWYK)
soundtouch src I used. (http://www.surina.net/soundtouch/soundtouch-1.4.0.zip)
About those errors. I googled some and this is what I found.
" Record theRecord defines theRecord on every cpp file that includes form.h. This causes the linker to see more than one definition of this variable and you get an error..
Move this definition to the actual cpp file where you need to use it. If more than one cpp file needs it then add a new line extern Record theRecord in the common header file.
Also as time progresses, try to learn to code without declaring global variables as you are doing here. Things like this really belong as members of a class."
Link (http://social.microsoft.com/Forums/en-US/vcgeneral/thread/1c415f93-afed-4b80-a244-c5a8c25bea99)
I have updated my first post detailing these steps.
Jeremy Duncan
6th March 2009, 12:30
I have finally made a true avisynth.dll.
here is my buildlog with no errors or warnings:
link (http://www.megaupload.com/?d=J21N4Z90)
I made a new part video; part three. Over at youtube.
It shows me build avisynth.dll
my youtube channel (http://www.youtube.com/foxhoundfan)
Part 1 and 2 show how to setup visual studio.
Guest
6th March 2009, 14:42
I have finally made a true avisynth.dll. Have you tested it to see if it works?
Jeremy Duncan
6th March 2009, 16:11
Have you tested it to see if it works?
No, but I will in a few minutes.
leeperry
6th March 2009, 20:52
but the true question is.....does mod2 work in MT now ? :cool:
Jeremy Duncan
8th March 2009, 12:22
I had successful in making the avisynth, but it was slow.
Then I was successful in making a fast avisynth dll, but it didn't work with every plugin.
Finally, today, I have made a fast avisynth dll that works better than the other two.
I have redone my youtube video showing how to make avisynth dll and reuploaded my dl and buildlog to the first post.
I have also changed the bottom part of my guide to show the steps I went through to make this dll.
The dll from the youtube video is the one I uploaded with the buildlog.
I fiddled with the mt avisynth 258 for two days and today I learned about the libs in the linker and now I know what neuron2 meant by using the directshow library.
So having learned that I tried my previous avisynth dll on my frame doubler configuration I use with ffdshow and it crashed, so I made on with the directshow lib added to the avisynth lib and the frame doubler configuration worked with no problem.
Feel free to add my guide to the media wiki.
Try it out yourself.
Try my dll I uploaded. :)
e-t172
25th March 2009, 09:30
Hi,
I'm trying to build the Avisynth 2.5.8 DLL with VC++ 2008 Express. I'm using avisynth within ffdshow only.
I managed to build a DLL in Release mode and it works just fine. However when I try in Debug mode (I need a Debug DLL), it doesn't work: I can build the DLL, but ffdshow crashes as soon as it tries to load Avisynth. When crashing a debugger does not show me any useful info.
I found a solution: it seems that the debug version of the included "Devil" library does not work correctly for some reason. So I had to use the release version of this library. If you come accross this problem, follow this procedure:
- Go to C/C++ -> Preprocessor -> Preprocessor Definitions and remove IL_DEBUG.
- Go to Linker -> Input and change "../distrib/lib/debug/devil-d.lib" to "../distrib/lib/devil.lib".
Now the Debug DLL works flawlessly and debugging works :)
Gavino
25th March 2009, 11:14
I'm trying to build the Avisynth 2.5.8 DLL with VC++ 2008 Express. [...] I managed to build a DLL in Release mode and it works just fine.
For the record, it would be useful if someone could confirm the 'right' way to go about this.
Did you follow Jeremy's instructions to do it, or take some other approach?
What differences, if any, would you suggest?
e-t172
25th March 2009, 12:37
I followed Jeremy's instructions. However I used VC++ express (not the trial version). I did not compile DirectShowSource and TCPDeliver (unchecked in configuration manager). For the stdafx.h problem I just replaced "stdafx.h" by "windows.h" and it works just fine. I used the last DirectX SDK (not the August 2007 one), using a dinput.h which I found with Google.
There might be some other slight differences with Jeremy's procedure though, but I can't remember which. If I have some time I will start from scratch and write down all the instructions.
Jeremy Duncan
8th April 2009, 21:59
I updated the first post so it's easier to understand.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.