Tinore Posted June 6, 2020 Share Posted June 6, 2020 Hi,I'am tinkering around the with the f4se files for the last few days and managed to compile f4se itself. But I wasn't able to add a project with a plugin itself.I followed this tutorial: https://forums.nexusmods.com/index.php?/topic/7759433-help-needed-compile-a-cpp-file-into-a-dll/and used an example plugin from github: https://github.com/Bradenm1/F4SE-example-pluginI think I messed up some includings but as I said I couldn't figure out what to do exactly.So is there an existing example plugin or can anybody provide one? Link to comment Share on other sites More sharing options...
dylbill Posted June 6, 2020 Share Posted June 6, 2020 You don't have to compile f4se and it's recommended that you don't do so. To use f4se you just need to install it and the source files in your Data folder, then you can use f4se functions in your own scripts. Link to comment Share on other sites More sharing options...
Tinore Posted June 6, 2020 Author Share Posted June 6, 2020 but I want to write an own function in c++ that I can call from a papyrus script. So I thought you have to create a .dll in c++ to add own plugins to f4se. Link to comment Share on other sites More sharing options...
dylbill Posted June 7, 2020 Share Posted June 7, 2020 Ahh, sorry I misread your original post, my bad. I've never made a .dll plugin for f4se so I can't help you there. Link to comment Share on other sites More sharing options...
isathar Posted June 10, 2020 Share Posted June 10, 2020 No idea if this is the recommended way to do it, but I'll try to outline how I'm setting up my own projects at the moment. The bonus of this approach is that you don't need to manually include any headers and source files in the project file, they'll get linked automagically. Just a quick disclaimer: I'm not all that great at any of this, and wouldn't be surprised if someone called out some massive mistakes I'm making somewhere :smile: Preparations:- Place the F4SE source code into a working directory (obviously).- Open src/f4se/f4se.sln with Visual Studio.- Open the f4se project's properties and change its Configuration Type to Static Library (.lib).- Edit the Post-Build options for the f4se, f4se_loader and f4se_steam_loader to remove the Post-Build Events.- You can compile the f4se solution now or wait until you're compiling your own project with it. - Just make sure you have it configured to build in Release Mode (otherwise you'll need to attach a debugger to finish building). Custom Project Setup:- Keep your project directory with the f4se source files in src/f4se/ .- Create a copy of src/f4se/f4se.sln, name it whatever and add your project to it. Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "YourProject", "YourProject\YourProject.vcxproj", "{YourProject's ID}" EndProject - Add the following to your project's vcxproj file to include F4SE (probably before rest of the inludes) : <ItemGroup> <ProjectReference Include="..\..\common\common_vc11.vcxproj"> <Project>{d4c128a1-73dc-4941-a453-ce55af239ba8}</Project> </ProjectReference> <ProjectReference Include="..\f4se\f4se.vcxproj"> <Project>{a236f69d-8ff9-4491-ac5f-45bf49448bbe}</Project> </ProjectReference> <ProjectReference Include="..\f4se_common\f4se_common.vcxproj"> <Project>{f1447a44-f26a-4680-8e20-2d9186766e51}</Project> </ProjectReference> </ItemGroup> - Also add the following to AdditionalIncludeDirectories to include f4se_common's path: $(SolutionDir)\..; - The building process will sometimes fail if you haven't built the rest of f4se before your custom project. Try to compile the full solution if your project refuses to compile. That should be it. A bunch of us are using Github to share and manage F4SE plugin source code. Just run a search for f4se on Github, and you should find some good examples. The source code for my probably completely unsafe dynamic patcher plugin can be found here and should be a better practical example than this short description. Link to comment Share on other sites More sharing options...
Tinore Posted June 17, 2020 Author Share Posted June 17, 2020 thank you for your answer. Even though I don't know how to make the copy of src/f4se/f4se.sln it worked just fine with your github project you provided. So I could remove your source code and replace it with my own and now it's compiling and working as expected! Link to comment Share on other sites More sharing options...
Recommended Posts