Skip to content

Commit 3915ff0

Browse files
authored
Export API Symbols for MSVC (#663)
By default, the Visual Studio C compiler doesn't export any symbols, so xtb.lib wasn't being created. Explicitly export C API functions using dllexport attribute. Signed-off-by: Ty <ty.balduf@schrodinger.com>
1 parent 579679a commit 3915ff0

File tree

6 files changed

+40
-1
lines changed

6 files changed

+40
-1
lines changed

src/api/calculator.f90

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ module xtb_api_calculator
3434
use xtb_type_molecule
3535
use xtb_type_calculator
3636
use xtb_xtb_calculator
37-
use xtb_main_setup, only : addSolvationModel
3837
implicit none
3938
private
4039

@@ -57,6 +56,7 @@ module xtb_api_calculator
5756

5857
function newCalculator_api() result(vcalc) &
5958
& bind(C, name="xtb_newCalculator")
59+
!DEC$ ATTRIBUTES DLLEXPORT :: newCalculator_api
6060
type(VCalculator), pointer :: calc
6161
type(c_ptr) :: vcalc
6262

@@ -70,6 +70,7 @@ end function newCalculator_api
7070

7171
subroutine delCalculator_api(vcalc) &
7272
& bind(C, name="xtb_delCalculator")
73+
!DEC$ ATTRIBUTES DLLEXPORT :: delCalculator_api
7374
type(c_ptr), intent(inout) :: vcalc
7475
type(VCalculator), pointer :: calc
7576

@@ -86,6 +87,7 @@ end subroutine delCalculator_api
8687

8788
subroutine loadGFNFF_api(venv, vmol, vcalc, charptr) &
8889
& bind(C, name="xtb_loadGFNFF")
90+
!DEC$ ATTRIBUTES DLLEXPORT :: loadGFNFF_api
8991
character(len=*), parameter :: source = 'xtb_api_loadGFNFF'
9092
type(c_ptr), value :: venv
9193
type(VEnvironment), pointer :: env
@@ -148,6 +150,7 @@ end subroutine loadGFNFF_api
148150

149151
subroutine loadGFN0xTB_api(venv, vmol, vcalc, charptr) &
150152
& bind(C, name="xtb_loadGFN0xTB")
153+
!DEC$ ATTRIBUTES DLLEXPORT :: loadGFN0xTB_api
151154
character(len=*), parameter :: source = 'xtb_api_loadGFN0xTB'
152155
type(c_ptr), value :: venv
153156
type(VEnvironment), pointer :: env
@@ -210,6 +213,7 @@ end subroutine loadGFN0xTB_api
210213

211214
subroutine loadGFN1xTB_api(venv, vmol, vcalc, charptr) &
212215
& bind(C, name="xtb_loadGFN1xTB")
216+
!DEC$ ATTRIBUTES DLLEXPORT :: loadGFN1xTB_api
213217
character(len=*), parameter :: source = 'xtb_api_loadGFN1xTB'
214218
type(c_ptr), value :: venv
215219
type(VEnvironment), pointer :: env
@@ -272,6 +276,7 @@ end subroutine loadGFN1xTB_api
272276

273277
subroutine loadGFN2xTB_api(venv, vmol, vcalc, charptr) &
274278
& bind(C, name="xtb_loadGFN2xTB")
279+
!DEC$ ATTRIBUTES DLLEXPORT :: loadGFN2xTB_api
275280
character(len=*), parameter :: source = 'xtb_api_loadGFN2xTB'
276281
type(c_ptr), value :: venv
277282
type(VEnvironment), pointer :: env
@@ -335,6 +340,7 @@ end subroutine loadGFN2xTB_api
335340
!> Add a solvation model to calculator (requires loaded parametrisation)
336341
subroutine setSolvent_api(venv, vcalc, charptr, state, temperature, grid) &
337342
& bind(C, name="xtb_setSolvent")
343+
!DEC$ ATTRIBUTES DLLEXPORT :: setSolvent_api
338344
character(len=*), parameter :: source = 'xtb_api_setSolvent'
339345
type(c_ptr), value :: venv
340346
type(VEnvironment), pointer :: env
@@ -411,6 +417,7 @@ end subroutine setSolvent_api
411417
!> Unset the solvation model
412418
subroutine releaseSolvent_api(venv, vcalc) &
413419
& bind(C, name="xtb_releaseSolvent")
420+
!DEC$ ATTRIBUTES DLLEXPORT :: releaseSolvent_api
414421
character(len=*), parameter :: source = 'xtb_api_setRelease'
415422
type(c_ptr), value :: venv
416423
type(VEnvironment), pointer :: env
@@ -442,6 +449,7 @@ end subroutine releaseSolvent_api
442449
!> Add a external charge potential to calculator (only supported in GFN1/2-xTB)
443450
subroutine setExternalCharges_api(venv, vcalc, npc, numbers, charges, positions) &
444451
& bind(C, name="xtb_setExternalCharges")
452+
!DEC$ ATTRIBUTES DLLEXPORT :: setExternalCharges_api
445453
character(len=*), parameter :: source = 'xtb_api_setExternalCharges'
446454
type(c_ptr), value :: venv
447455
type(VEnvironment), pointer :: env
@@ -504,6 +512,7 @@ end subroutine setExternalCharges_api
504512
!> Unset the external charge potential
505513
subroutine releaseExternalCharges_api(venv, vcalc) &
506514
& bind(C, name="xtb_releaseExternalCharges")
515+
!DEC$ ATTRIBUTES DLLEXPORT :: releaseExternalCharges_api
507516
character(len=*), parameter :: source = 'xtb_api_releaseExternalCharges'
508517
type(c_ptr), value :: venv
509518
type(VEnvironment), pointer :: env
@@ -536,6 +545,7 @@ end subroutine releaseExternalCharges_api
536545

537546
subroutine setAccuracy_api(venv, vcalc, accuracy) &
538547
& bind(C, name="xtb_setAccuracy")
548+
!DEC$ ATTRIBUTES DLLEXPORT :: setAccuracy_api
539549
character(len=*), parameter :: source = 'xtb_api_setAccuracy'
540550
type(c_ptr), value :: venv
541551
type(VEnvironment), pointer :: env
@@ -578,6 +588,7 @@ end subroutine setAccuracy_api
578588

579589
subroutine setMaxIter_api(venv, vcalc, maxiter) &
580590
& bind(C, name="xtb_setMaxIter")
591+
!DEC$ ATTRIBUTES DLLEXPORT :: setMaxIter_api
581592
character(len=*), parameter :: source = 'xtb_api_setMaxIter'
582593
type(c_ptr), value :: venv
583594
type(VEnvironment), pointer :: env
@@ -616,6 +627,7 @@ end subroutine setMaxIter_api
616627

617628
subroutine setElectronicTemp_api(venv, vcalc, temperature) &
618629
& bind(C, name="xtb_setElectronicTemp")
630+
!DEC$ ATTRIBUTES DLLEXPORT :: setElectronicTemp_api
619631
character(len=*), parameter :: source = 'xtb_api_setElectronicTemp'
620632
type(c_ptr), value :: venv
621633
type(VEnvironment), pointer :: env

src/api/environment.f90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module xtb_api_environment
4545
!> Create new xtb calculation environment object
4646
function newEnvironment_api() result(venv) &
4747
& bind(C, name="xtb_newEnvironment")
48+
!DEC$ ATTRIBUTES DLLEXPORT :: newEnvironment_api
4849
type(VEnvironment), pointer :: env
4950
type(c_ptr) :: venv
5051

@@ -61,6 +62,7 @@ end function newEnvironment_api
6162
!> Delete a xtb calculation environment object
6263
subroutine delEnvironment_api(venv) &
6364
& bind(C, name="xtb_delEnvironment")
65+
!DEC$ ATTRIBUTES DLLEXPORT :: delEnvironment_api
6466
type(c_ptr), intent(inout) :: venv
6567
type(VEnvironment), pointer :: env
6668

@@ -79,6 +81,7 @@ end subroutine delEnvironment_api
7981
!> Check current status of calculation environment
8082
function checkEnvironment_api(venv) result(status) &
8183
& bind(C, name="xtb_checkEnvironment")
84+
!DEC$ ATTRIBUTES DLLEXPORT :: checkEnvironment_api
8285
type(c_ptr), value :: venv
8386
type(VEnvironment), pointer :: env
8487
integer(c_int) :: status
@@ -102,6 +105,7 @@ end function checkEnvironment_api
102105
!> Show and empty error stack
103106
subroutine showEnvironment_api(venv, charptr) &
104107
& bind(C, name="xtb_showEnvironment")
108+
!DEC$ ATTRIBUTES DLLEXPORT :: showEnvironment_api
105109
type(c_ptr), value :: venv
106110
type(VEnvironment), pointer :: env
107111
character(kind=c_char), intent(in), optional :: charptr(*)
@@ -126,6 +130,7 @@ end subroutine showEnvironment_api
126130
!> Bind output from this environment
127131
subroutine setOutput_api(venv, charptr) &
128132
& bind(C, name="xtb_setOutput")
133+
!DEC$ ATTRIBUTES DLLEXPORT :: setOutput_api
129134
character(len=*), parameter :: source = 'xtb_api_setOutput'
130135
type(c_ptr), value :: venv
131136
type(VEnvironment), pointer :: env
@@ -160,6 +165,7 @@ end subroutine setOutput_api
160165
!> Release output unit from this environment
161166
subroutine releaseOutput_api(venv) &
162167
& bind(C, name="xtb_releaseOutput")
168+
!DEC$ ATTRIBUTES DLLEXPORT :: releaseOutput_api
163169
character(len=*), parameter :: source = 'xtb_api_releaseOutput'
164170
type(c_ptr), value :: venv
165171
type(VEnvironment), pointer :: env
@@ -184,6 +190,7 @@ end subroutine releaseOutput_api
184190
!> Set verbosity of calculation output
185191
subroutine setVerbosity_api(venv, verbosity) &
186192
& bind(C, name="xtb_setVerbosity")
193+
!DEC$ ATTRIBUTES DLLEXPORT :: setVerbosity_api
187194
character(len=*), parameter :: source = 'xtb_api_setVerbosity'
188195
type(c_ptr), value :: venv
189196
type(VEnvironment), pointer :: env
@@ -206,6 +213,7 @@ end subroutine setVerbosity_api
206213
!> Set verbosity of calculation output
207214
subroutine getError_api(venv, charptr, buffersize) &
208215
& bind(C, name="xtb_getError")
216+
!DEC$ ATTRIBUTES DLLEXPORT :: setVerbosity_api, getError_api
209217
character(len=*), parameter :: source = 'xtb_api_getError'
210218
type(c_ptr), value :: venv
211219
type(VEnvironment), pointer :: env

src/api/interface.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module xtb_api_interface
3939

4040
subroutine singlepoint_api(venv, vmol, vcalc, vres) &
4141
& bind(C, name="xtb_singlepoint")
42+
!DEC$ ATTRIBUTES DLLEXPORT :: singlepoint_api
4243
character(len=*), parameter :: source = 'xtb_api_singlepoint'
4344
type(c_ptr), value :: venv
4445
type(VEnvironment), pointer :: env

src/api/molecule.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module xtb_api_molecule
4545
function newMolecule_api(venv, natoms, numbers, positions, charge, uhf, lattice, &
4646
& periodic) result(vmol) &
4747
& bind(C, name="xtb_newMolecule")
48+
!DEC$ ATTRIBUTES DLLEXPORT :: newMolecule_api
4849
character(len=*), parameter :: source = 'xtb_api_newMolecule'
4950
type(c_ptr), value :: venv
5051
type(VEnvironment), pointer :: env
@@ -95,6 +96,7 @@ end function newMolecule_api
9596

9697
subroutine delMolecule_api(vmol) &
9798
& bind(C, name="xtb_delMolecule")
99+
!DEC$ ATTRIBUTES DLLEXPORT :: delMolecule_api
98100
type(c_ptr), intent(inout) :: vmol
99101
type(VMolecule), pointer :: mol
100102

@@ -111,6 +113,7 @@ end subroutine delMolecule_api
111113

112114
subroutine updateMolecule_api(venv, vmol, positions, lattice) &
113115
& bind(C, name="xtb_updateMolecule")
116+
!DEC$ ATTRIBUTES DLLEXPORT :: updateMolecule_api
114117
character(len=*), parameter :: source = 'xtb_api_updateMolecule'
115118
type(c_ptr), value :: venv
116119
type(VEnvironment), pointer :: env

src/api/results.f90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module xtb_api_results
5151
!> Create new singlepoint results object
5252
function newResults_api() result(vres) &
5353
& bind(C, name="xtb_newResults")
54+
!DEC$ ATTRIBUTES DLLEXPORT :: newResults_api
5455
type(VResults), pointer :: res
5556
type(c_ptr) :: vres
5657

@@ -65,6 +66,7 @@ end function newResults_api
6566
!> Delete singlepoint results object
6667
subroutine delResults_api(vres) &
6768
& bind(C, name="xtb_delResults")
69+
!DEC$ ATTRIBUTES DLLEXPORT :: delResults_api
6870
type(c_ptr), intent(inout) :: vres
6971
type(VResults), pointer :: res
7072

@@ -82,6 +84,7 @@ end subroutine delResults_api
8284
!> Create copy from a singlepoint results object
8385
function copyResults_api(vold) result(vres) &
8486
& bind(C, name="xtb_copyResults")
87+
!DEC$ ATTRIBUTES DLLEXPORT :: copyResults_api
8588
type(VResults), pointer :: res
8689
type(c_ptr) :: vres
8790
type(VResults), pointer :: old
@@ -103,6 +106,7 @@ end function copyResults_api
103106
!> Query singlepoint results object for energy
104107
subroutine getEnergy_api(venv, vres, dptr) &
105108
& bind(C, name="xtb_getEnergy")
109+
!DEC$ ATTRIBUTES DLLEXPORT :: getEnergy_api
106110
character(len=*), parameter :: source = "xtb_api_getEnergy"
107111
type(c_ptr), value :: venv
108112
type(VEnvironment), pointer :: env
@@ -135,6 +139,7 @@ end subroutine getEnergy_api
135139
!> Query singlepoint results object for gradient
136140
subroutine getGradient_api(venv, vres, dptr) &
137141
& bind(C, name="xtb_getGradient")
142+
!DEC$ ATTRIBUTES DLLEXPORT :: getGradient_api
138143
character(len=*), parameter :: source = "xtb_api_getGradient"
139144
type(c_ptr), value :: venv
140145
type(VEnvironment), pointer :: env
@@ -167,6 +172,7 @@ end subroutine getGradient_api
167172
!> Query singlepoint results object for gradients on external charges
168173
subroutine getPCGradient_api(venv, vres, dptr) &
169174
& bind(C, name="xtb_getPCGradient")
175+
!DEC$ ATTRIBUTES DLLEXPORT :: getPCGradient_api
170176
character(len=*), parameter :: source = "xtb_api_getGradient"
171177
type(c_ptr), value :: venv
172178
type(VEnvironment), pointer :: env
@@ -199,6 +205,7 @@ end subroutine getPCGradient_api
199205
!> Query singlepoint results object for virial
200206
subroutine getVirial_api(venv, vres, dptr) &
201207
& bind(C, name="xtb_getVirial")
208+
!DEC$ ATTRIBUTES DLLEXPORT :: getVirial_api
202209
character(len=*), parameter :: source = "xtb_api_getVirial"
203210
type(c_ptr), value :: venv
204211
type(VEnvironment), pointer :: env
@@ -231,6 +238,7 @@ end subroutine getVirial_api
231238
!> Query singlepoint results object for dipole moment
232239
subroutine getDipole_api(venv, vres, dptr) &
233240
& bind(C, name="xtb_getDipole")
241+
!DEC$ ATTRIBUTES DLLEXPORT :: getDipole_api
234242
character(len=*), parameter :: source = "xtb_api_getDipole"
235243
type(c_ptr), value :: venv
236244
type(VEnvironment), pointer :: env
@@ -263,6 +271,7 @@ end subroutine getDipole_api
263271
!> Query singlepoint results object for partial charges
264272
subroutine getCharges_api(venv, vres, dptr) &
265273
& bind(C, name="xtb_getCharges")
274+
!DEC$ ATTRIBUTES DLLEXPORT :: getCharges_api
266275
character(len=*), parameter :: source = "xtb_api_getCharges"
267276
type(c_ptr), value :: venv
268277
type(VEnvironment), pointer :: env
@@ -295,6 +304,7 @@ end subroutine getCharges_api
295304
!> Query singlepoint results object for bond orders
296305
subroutine getBondOrders_api(venv, vres, dptr) &
297306
& bind(C, name="xtb_getBondOrders")
307+
!DEC$ ATTRIBUTES DLLEXPORT :: getBondOrders_api
298308
character(len=*), parameter :: source = "xtb_api_getBondOrders"
299309
type(c_ptr), value :: venv
300310
type(VEnvironment), pointer :: env
@@ -327,6 +337,7 @@ end subroutine getBondOrders_api
327337
!> Query singlepoint results object for bond orders
328338
subroutine getNao_api(venv, vres, iptr) &
329339
& bind(C, name="xtb_getNao")
340+
!DEC$ ATTRIBUTES DLLEXPORT :: getNao_api
330341
character(len=*), parameter :: source = "xtb_api_getNao"
331342
type(c_ptr), value :: venv
332343
type(VEnvironment), pointer :: env
@@ -358,6 +369,7 @@ end subroutine getNao_api
358369
!> Query singlepoint results object for orbital energies
359370
subroutine getOrbitalEigenvalues_api(venv, vres, dptr) &
360371
& bind(C, name="xtb_getOrbitalEigenvalues")
372+
!DEC$ ATTRIBUTES DLLEXPORT :: getOrbitalEigenvalues_api
361373
character(len=*), parameter :: source = "xtb_api_getOrbitalEigenvalues"
362374
type(c_ptr), value :: venv
363375
type(VEnvironment), pointer :: env
@@ -391,6 +403,7 @@ end subroutine getOrbitalEigenvalues_api
391403
!> Query singlepoint results object for occupation numbers
392404
subroutine getOrbitalOccupations_api(venv, vres, dptr) &
393405
& bind(C, name="xtb_getOrbitalOccupations")
406+
!DEC$ ATTRIBUTES DLLEXPORT :: getOrbitalOccupations_api
394407
character(len=*), parameter :: source = "xtb_api_getOrbitalOccupations"
395408
type(c_ptr), value :: venv
396409
type(VEnvironment), pointer :: env
@@ -424,6 +437,7 @@ end subroutine getOrbitalOccupations_api
424437
!> Query singlepoint results object for orbital coefficients
425438
subroutine getOrbitalCoefficients_api(venv, vres, dptr) &
426439
& bind(C, name="xtb_getOrbitalCoefficients")
440+
!DEC$ ATTRIBUTES DLLEXPORT :: getOrbitalCoefficients_api
427441
character(len=*), parameter :: source = "xtb_api_getOrbitalCoefficients"
428442
type(c_ptr), value :: venv
429443
type(VEnvironment), pointer :: env

src/api/version.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module xtb_api_version
3333

3434
function getAPIVersion_api() result(version) &
3535
& bind(C, name="xtb_getAPIVersion")
36+
!DEC$ ATTRIBUTES DLLEXPORT :: getAPIVersion_api
3637
integer(c_int) :: version
3738

3839
version = 10000_c_int * apiMajor + 100_c_int * apiMinor + apiPatch

0 commit comments

Comments
 (0)